Skip to content

Commit

Permalink
Add specs for redundant SafeAutoCorrect: true and AutoCorrect: true
Browse files Browse the repository at this point in the history
This PR adds specs redandant `SafeAutoCorrect: true` and `AutoCorrect: true` config:
And it removes the redundant config detected below to fix the failed specs:

```console
$ bundle exec rspec spec/project_spec.rb
(snip)

Failures:

  1) RuboCop Project default configuration file does not include `AutoCorrect: true`
     Failure/Error: expect(safe).not_to be(true), "`#{name}` has unnecessary `#{metadata}: true` config."
       `Layout/LineContinuationSpacing` has unnecessary `AutoCorrect: true` config.
     # ./spec/project_spec.rb:131:in `block (5 levels) in <top (required)>'
     # ./spec/project_spec.rb:129:in `each'
     # ./spec/project_spec.rb:129:in `block (4 levels) in <top (required)>'

  2) RuboCop Project default configuration file does not include `SafeAutoCorrect: true`
     Failure/Error: expect(safe).not_to be(true), "`#{name}` has unnecessary `#{metadata}: true` config."
       `Layout/LineContinuationSpacing` has unnecessary `SafeAutoCorrect: true` config.
     # ./spec/project_spec.rb:131:in `block (5 levels) in <top (required)>'
     # ./spec/project_spec.rb:129:in `each'
     # ./spec/project_spec.rb:129:in `block (4 levels) in <top (required)>'

Finished in 2.12 seconds (files took 1.12 seconds to load)
107 examples, 2 failures

Failed examples:

rspec './spec/project_spec.rb[1:1:12]' # RuboCop Project default configuration file does not include `AutoCorrect: true`
rspec './spec/project_spec.rb[1:1:11]' # RuboCop Project default configuration file does not include `SafeAutoCorrect: true`
```
  • Loading branch information
koic committed Apr 10, 2023
1 parent 27b7ceb commit b0e6591
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,6 @@ Layout/LineContinuationLeadingSpace:
Layout/LineContinuationSpacing:
Description: 'Checks the spacing in front of backslash in line continuations.'
Enabled: pending
AutoCorrect: true
SafeAutoCorrect: true
VersionAdded: '1.31'
EnforcedStyle: space
SupportedStyles:
Expand Down
10 changes: 6 additions & 4 deletions spec/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,12 @@ def expected
end
# rubocop:enable RSpec/NoExpectationExample

it 'does not include `Safe: true`' do
cop_names.each do |name|
safe = config.dig(name, 'Safe')
expect(safe).not_to be(true), "`#{name}` has unnecessary `Safe: true` config."
%w[Safe SafeAutoCorrect AutoCorrect].each do |metadata|
it "does not include `#{metadata}: true`" do
cop_names.each do |cop_name|
safe = config.dig(cop_name, metadata)
expect(safe).not_to be(true), "`#{cop_name}` has unnecessary `#{metadata}: true` config."
end
end
end
end
Expand Down

0 comments on commit b0e6591

Please sign in to comment.