Skip to content

Commit 65cc169

Browse files
lumeetNeodelf
authored andcommitted
Reduce complexity in CLI
Extract `execute_runner` from `RuboCop::CLI#run`.
1 parent 82bf52e commit 65cc169

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/rubocop/cli.rb

+13-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,7 @@ def run(args = ARGV)
2525
act_on_options
2626
apply_default_formatter
2727

28-
runner = Runner.new(@options, @config_store)
29-
trap_interrupt(runner)
30-
all_passed = runner.run(paths)
31-
display_warning_summary(runner.warnings)
32-
display_error_summary(runner.errors)
33-
maybe_print_corrected_source
34-
35-
all_passed && !runner.aborting? && runner.errors.empty? ? 0 : 1
28+
execute_runner(paths)
3629
rescue RuboCop::Error => e
3730
$stderr.puts Rainbow("Error: #{e.message}").red
3831
return 2
@@ -72,6 +65,18 @@ def act_on_options
7265
end
7366
end
7467

68+
def execute_runner(paths)
69+
runner = Runner.new(@options, @config_store)
70+
71+
trap_interrupt(runner)
72+
all_passed = runner.run(paths)
73+
display_warning_summary(runner.warnings)
74+
display_error_summary(runner.errors)
75+
maybe_print_corrected_source
76+
77+
all_passed && !runner.aborting? && runner.errors.empty? ? 0 : 1
78+
end
79+
7580
def handle_exiting_options
7681
return unless Options::EXITING_OPTIONS.any? { |o| @options.key? o }
7782

0 commit comments

Comments
 (0)