class Grubocop::Analyzer
Public Class Methods
execute(options)
click to toggle source
# File lib/grubocop/analyzer.rb, line 5 def self.execute(options) analyzer = new(options) all_files = analyzer.touched_files_on_branch return if all_files.empty? analyzer.check(all_files) rescue analyzer.check end
new(options)
click to toggle source
# File lib/grubocop/analyzer.rb, line 15 def initialize(options) @options = options end
Public Instance Methods
check(paths = [])
click to toggle source
# File lib/grubocop/analyzer.rb, line 19 def check(paths = []) paths = paths.join(' ') exec "rubocop #{paths}" end
ruby_file?(file)
click to toggle source
# File lib/grubocop/analyzer.rb, line 31 def ruby_file?(file) File.extname(file) == '.rb' end
touched_files_on_branch()
click to toggle source
# File lib/grubocop/analyzer.rb, line 24 def touched_files_on_branch raise 'No target branch specified!' if @options[:target_branch].blank? files = `git diff --diff-filter=ACMR --name-only #{@options[:target_branch]}` files.split("\n").select { |file| ruby_file?(file) } end