Skip to content

Commit

Permalink
Merge pull request #1304 from rubocop/enable-new-cops
Browse files Browse the repository at this point in the history
Enable new cops
  • Loading branch information
pirj committed Jun 22, 2022
2 parents dbbef32 + 08cc387 commit 02cbb08
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ If you have created a new cop:

* [ ] Added the new cop to `config/default.yml`.
* [ ] The cop is configured as `Enabled: pending` in `config/default.yml`.
* [ ] The cop is configured as `Enabled: true` in `.rubocop.yml`.
* [ ] The cop documents examples of good and bad code.
* [ ] The tests assert both that bad code is reported and that good code is not reported.
* [ ] Set `VersionAdded` in `default/config.yml` to the next minor version.
Expand Down
36 changes: 29 additions & 7 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ AllCops:
- 'tmp/**/*'
- 'spec/smoke_tests/**/*.rb'

# See https://github.com/rubocop/rubocop/issues/6410
Layout/HashAlignment:
Enabled: false
EnforcedHashRocketStyle:
- key
- table
EnforcedColonStyle:
- key
- table

Layout/LineLength:
Max: 80 # default: 120
Expand All @@ -29,11 +33,6 @@ Layout/MultilineMethodCallIndentation:
Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Lint/BooleanSymbol:
Exclude:
- lib/rubocop/cop/rspec/expect_actual.rb
- lib/rubocop/cop/rspec/focus.rb

Lint/InterpolationCheck:
Exclude:
- spec/**/*.rb
Expand Down Expand Up @@ -85,3 +84,26 @@ RSpec/DescribeClass:
Style/FormatStringToken:
Exclude:
- spec/rubocop/**/*.rb

# Enable our own pending cops.

RSpec/BeEq:
Enabled: true
RSpec/BeNil:
Enabled: true
RSpec/ChangeByZero:
Enabled: true
RSpec/ExcessiveDocstringSpacing:
Enabled: true
RSpec/IdenticalEqualityAssertion:
Enabled: true
RSpec/SubjectDeclaration:
Enabled: true
RSpec/VerifiedDoubleReference:
Enabled: true
RSpec/Capybara/SpecificMatcher:
Enabled: true
RSpec/FactoryBot/SyntaxMethods:
Enabled: true
RSpec/Rails/AvoidSetupHook:
Enabled: true
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/scattered_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def on_block(node)
occurrences.each do |occurrence|
lines_except_current = lines - [occurrence.first_line]
message = format(MSG, hook_name: occurrences.first.method_name,
lines: lines_msg(lines_except_current))
lines: lines_msg(lines_except_current))
add_offense(occurrence, message: message)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/cop/rspec/scattered_let_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::ScatteredLet do
it 'flags `let` after the first different node ' do
it 'flags `let` after the first different node' do
expect_offense(<<-RUBY)
RSpec.describe User do
let(:a) { a }
Expand Down
10 changes: 5 additions & 5 deletions spec/rubocop/rspec/config_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
'Setting' => 'forty two'
},
'RSpec/Foo' => {
'Config' => 2,
'Enabled' => true
'Config' => 2,
'Enabled' => true
},
'RSpec/Bar' => {
'Enabled' => true
'Enabled' => true
},
'RSpec/Baz' => {
'Enabled' => true,
'StyleGuide' => '#buzz'
'Enabled' => true,
'StyleGuide' => '#buzz'
}
}
end
Expand Down
4 changes: 3 additions & 1 deletion spec/rubocop/rspec/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def example(source)
end

it 'returns nil for examples without doc strings' do
expect(example('it { foo }').doc_string).to be(nil)
expect(example('it { foo }').doc_string).to be_nil
end

it 'extracts keywords' do
Expand All @@ -58,12 +58,14 @@ def example(source)
end

describe 'value object semantics' do
# rubocop:disable RSpec/IdenticalEqualityAssertion
it 'compares by value' do
aggregate_failures 'equality semantics' do
expect(example('it("foo")')).to eq(example('it("foo")'))
expect(example('it("foo")')).not_to eq(example('it("bar")'))
end
end
# rubocop:enable RSpec/IdenticalEqualityAssertion

it 'can be used as a key in a hash' do
hash = {}
Expand Down

0 comments on commit 02cbb08

Please sign in to comment.