We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If you run rubocop --auto-gen-config against a codebase that contains a symbol array with spaces, eg.:
rubocop --auto-gen-config
%w[Paris Sydney New\ York]
the offense is not added to rubocop_todo.yml . Subsequent rubocop runs will always have an offense on this array.
rubocop_todo.yml
rubocop
The file containing the array should be excluded under the Style/WordArray cop in rubocop_todo.yml
Style/WordArray
The file is not excluded.
This can be reproduced with this spec:
diff --git a/spec/rubocop/cli/auto_gen_config_spec.rb b/spec/rubocop/cli/auto_gen_config_spec.rb index 0691669b4..240a0bfa2 100644 --- a/spec/rubocop/cli/auto_gen_config_spec.rb +++ b/spec/rubocop/cli/auto_gen_config_spec.rb @@ -300,6 +300,31 @@ RSpec.describe 'RuboCop::CLI --auto-gen-config', :isolated_environment do # rubo end end + it 'excludes the complex array when the style is mixed for Style/WordArray' do + create_file( + 'example1.rb', + [ + '# frozen_string_literal: true', + '', + '%w[France Australia USA] +', + ' %w[Paris Sydney New\ York]' + ] + ) + + expect(cli.run(['--auto-gen-config'])).to eq(0) + expect(File.readlines('.rubocop_todo.yml')[8..-1].join) + .to eq(<<~YAML) + # Offense count: 1 + # Cop supports --auto-correct. + # Configuration parameters: MinSize, WordRegex. + # SupportedStyles: percent, brackets + Style/WordArray: + EnforcedStyle: percent + Exclude: + - example1.rb + YAML + end + it 'overwrites an existing todo file' do create_file('example1.rb', ['# frozen_string_literal: true', '',
The spec should pass, but instead it fails with the diff showing that the following is missing:
- Exclude: - - example1.rb
Issue was encountered in app with the following version:
➜ finbot (dependabot/bundler/rubocop-1.21.0) ✗ be rubocop -V 1.21.0 (using Parser 3.0.2.0, rubocop-ast 1.12.0, running on ruby 2.5.7 x86_64-darwin19)
Spec was run against rubocop/master. HEAD at the time was 8b5d234.
The text was updated successfully, but these errors were encountered:
[Fix rubocop#10135] Fix Style/WordArray to exclude files in `--auto…
ff09a4c
…-gen-config` when `percent` style is given but brackets are required.
--auto-gen-config
percent
[Fix #10135] Fix Style/WordArray to exclude files in `--auto-gen-co…
46d8867
…nfig` when `percent` style is given but brackets are required.
Successfully merging a pull request may close this issue.
If you run
rubocop --auto-gen-config
against a codebase that contains a symbol array with spaces, eg.:the offense is not added to
rubocop_todo.yml
. Subsequentrubocop
runs will always have an offense on this array.Expected behavior
The file containing the array should be excluded under the
Style/WordArray
cop inrubocop_todo.yml
Actual behavior
The file is not excluded.
Steps to reproduce the problem
This can be reproduced with this spec:
The spec should pass, but instead it fails with the diff showing that the following is missing:
RuboCop version
Issue was encountered in app with the following version:
Spec was run against rubocop/master. HEAD at the time was 8b5d234.
The text was updated successfully, but these errors were encountered: