class RDocRuboCop::RuboCopRunner
Public Class Methods
new(paths = [], options: [])
click to toggle source
# File lib/rdoc_rubocop/rubocop_runner.rb, line 5 def initialize(paths = [], options: []) @paths = paths @options = options @cli = RuboCop::CLI.new end
Public Instance Methods
run()
click to toggle source
# File lib/rdoc_rubocop/rubocop_runner.rb, line 11 def run if @options.include?("-a") || @options.include?("--auto-correct") format else style_check end end
Private Instance Methods
format()
click to toggle source
# File lib/rdoc_rubocop/rubocop_runner.rb, line 21 def format targets = source_files file_paths = targets.flat_map(&:source_code_file_paths) if file_paths.empty? report_zero else exit_code = run_cli(file_paths) targets.each(&:correct!) exit_code end end
report_zero()
click to toggle source
Report with a message: “Inspecting 0 files”
# File lib/rdoc_rubocop/rubocop_runner.rb, line 60 def report_zero non_existing_filepath = Dir.glob("#{__dir__}/*").sort.last.succ options, _ = RuboCop::Options.new.parse(@options) config_store = RuboCop::ConfigStore.new runner = RuboCop::Runner.new(options, config_store).run([non_existing_filepath]) end
run_cli(source_code_file_paths)
click to toggle source
# File lib/rdoc_rubocop/rubocop_runner.rb, line 49 def run_cli(source_code_file_paths) change_dotfilenames_temporary do @cli.run(@options + source_code_file_paths) end end
source_files()
click to toggle source
# File lib/rdoc_rubocop/rubocop_runner.rb, line 55 def source_files @paths.map(&Lang::Base::SourceFile.method(:build)) end
style_check()
click to toggle source
# File lib/rdoc_rubocop/rubocop_runner.rb, line 35 def style_check targets = source_files file_paths = targets.flat_map(&:source_code_file_paths) if file_paths.empty? report_zero else run_cli(file_paths) end end