lib/rubocop/cli/command/auto_generate_config.rb in rubocop-1.46.0 vs lib/rubocop/cli/command/auto_generate_config.rb in rubocop-1.47.0

- old
+ new

@@ -14,10 +14,11 @@ PHASE_1 = 'Phase 1 of 2: run Layout/LineLength cop' PHASE_2 = 'Phase 2 of 2: run all cops' PHASE_1_OVERRIDDEN = '(skipped because the default Layout/LineLength:Max is overridden)' PHASE_1_DISABLED = '(skipped because Layout/LineLength is disabled)' + PHASE_1_SKIPPED = '(skipped because a list of cops is passed to the `--only` flag)' def run add_formatter reset_config_and_auto_gen_file line_length_contents = maybe_run_line_length_cop @@ -29,10 +30,12 @@ def maybe_run_line_length_cop if !line_length_enabled?(@config_store.for_pwd) skip_line_length_cop(PHASE_1_DISABLED) elsif !same_max_line_length?(@config_store.for_pwd, ConfigLoader.default_configuration) skip_line_length_cop(PHASE_1_OVERRIDDEN) + elsif options_has_only_flag? + skip_line_length_cop(PHASE_1_SKIPPED) else run_line_length_cop end end @@ -53,9 +56,13 @@ line_length_cop(config)['Max'] end def line_length_cop(config) config.for_cop('Layout/LineLength') + end + + def options_has_only_flag? + @options[:only] end # Do an initial run with only Layout/LineLength so that cops that # depend on Layout/LineLength:Max get the correct value for that # parameter.