lib/rubocop/cli/command/auto_generate_config.rb in rubocop-1.62.0 vs lib/rubocop/cli/command/auto_generate_config.rb in rubocop-1.62.1

- old
+ new

@@ -15,11 +15,14 @@ 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)' + PHASE_1_SKIPPED_ONLY_COPS = + '(skipped because a list of cops is passed to the `--only` flag)' + PHASE_1_SKIPPED_ONLY_EXCLUDE = + '(skipped because only excludes will be generated due to `--auto-gen-only-exclude` flag)' def run add_formatter reset_config_and_auto_gen_file line_length_contents = maybe_run_line_length_cop @@ -27,16 +30,18 @@ end private def maybe_run_line_length_cop - if !line_length_enabled?(@config_store.for_pwd) + if only_exclude? + skip_line_length_cop(PHASE_1_SKIPPED_ONLY_EXCLUDE) + elsif !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) + skip_line_length_cop(PHASE_1_SKIPPED_ONLY_COPS) else run_line_length_cop end end @@ -61,9 +66,13 @@ config.for_cop('Layout/LineLength') end def options_has_only_flag? @options[:only] + end + + def only_exclude? + @options[:auto_gen_only_exclude] 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.