Skip to content

Commit 02cbb08

Browse files
authored
Merge pull request #1304 from rubocop/enable-new-cops
Enable new cops
2 parents dbbef32 + 08cc387 commit 02cbb08

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ If you have created a new cop:
1515

1616
* [ ] Added the new cop to `config/default.yml`.
1717
* [ ] The cop is configured as `Enabled: pending` in `config/default.yml`.
18+
* [ ] The cop is configured as `Enabled: true` in `.rubocop.yml`.
1819
* [ ] The cop documents examples of good and bad code.
1920
* [ ] The tests assert both that bad code is reported and that good code is not reported.
2021
* [ ] Set `VersionAdded` in `default/config.yml` to the next minor version.

.rubocop.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ AllCops:
1414
- 'tmp/**/*'
1515
- 'spec/smoke_tests/**/*.rb'
1616

17-
# See https://github.com/rubocop/rubocop/issues/6410
1817
Layout/HashAlignment:
19-
Enabled: false
18+
EnforcedHashRocketStyle:
19+
- key
20+
- table
21+
EnforcedColonStyle:
22+
- key
23+
- table
2024

2125
Layout/LineLength:
2226
Max: 80 # default: 120
@@ -29,11 +33,6 @@ Layout/MultilineMethodCallIndentation:
2933
Layout/MultilineOperationIndentation:
3034
EnforcedStyle: indented
3135

32-
Lint/BooleanSymbol:
33-
Exclude:
34-
- lib/rubocop/cop/rspec/expect_actual.rb
35-
- lib/rubocop/cop/rspec/focus.rb
36-
3736
Lint/InterpolationCheck:
3837
Exclude:
3938
- spec/**/*.rb
@@ -85,3 +84,26 @@ RSpec/DescribeClass:
8584
Style/FormatStringToken:
8685
Exclude:
8786
- spec/rubocop/**/*.rb
87+
88+
# Enable our own pending cops.
89+
90+
RSpec/BeEq:
91+
Enabled: true
92+
RSpec/BeNil:
93+
Enabled: true
94+
RSpec/ChangeByZero:
95+
Enabled: true
96+
RSpec/ExcessiveDocstringSpacing:
97+
Enabled: true
98+
RSpec/IdenticalEqualityAssertion:
99+
Enabled: true
100+
RSpec/SubjectDeclaration:
101+
Enabled: true
102+
RSpec/VerifiedDoubleReference:
103+
Enabled: true
104+
RSpec/Capybara/SpecificMatcher:
105+
Enabled: true
106+
RSpec/FactoryBot/SyntaxMethods:
107+
Enabled: true
108+
RSpec/Rails/AvoidSetupHook:
109+
Enabled: true

lib/rubocop/cop/rspec/scattered_setup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def on_block(node)
3535
occurrences.each do |occurrence|
3636
lines_except_current = lines - [occurrence.first_line]
3737
message = format(MSG, hook_name: occurrences.first.method_name,
38-
lines: lines_msg(lines_except_current))
38+
lines: lines_msg(lines_except_current))
3939
add_offense(occurrence, message: message)
4040
end
4141
end

spec/rubocop/cop/rspec/scattered_let_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
RSpec.describe RuboCop::Cop::RSpec::ScatteredLet do
4-
it 'flags `let` after the first different node ' do
4+
it 'flags `let` after the first different node' do
55
expect_offense(<<-RUBY)
66
RSpec.describe User do
77
let(:a) { a }

spec/rubocop/rspec/config_formatter_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
'Setting' => 'forty two'
1010
},
1111
'RSpec/Foo' => {
12-
'Config' => 2,
13-
'Enabled' => true
12+
'Config' => 2,
13+
'Enabled' => true
1414
},
1515
'RSpec/Bar' => {
16-
'Enabled' => true
16+
'Enabled' => true
1717
},
1818
'RSpec/Baz' => {
19-
'Enabled' => true,
20-
'StyleGuide' => '#buzz'
19+
'Enabled' => true,
20+
'StyleGuide' => '#buzz'
2121
}
2222
}
2323
end

spec/rubocop/rspec/example_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def example(source)
3939
end
4040

4141
it 'returns nil for examples without doc strings' do
42-
expect(example('it { foo }').doc_string).to be(nil)
42+
expect(example('it { foo }').doc_string).to be_nil
4343
end
4444

4545
it 'extracts keywords' do
@@ -58,12 +58,14 @@ def example(source)
5858
end
5959

6060
describe 'value object semantics' do
61+
# rubocop:disable RSpec/IdenticalEqualityAssertion
6162
it 'compares by value' do
6263
aggregate_failures 'equality semantics' do
6364
expect(example('it("foo")')).to eq(example('it("foo")'))
6465
expect(example('it("foo")')).not_to eq(example('it("bar")'))
6566
end
6667
end
68+
# rubocop:enable RSpec/IdenticalEqualityAssertion
6769

6870
it 'can be used as a key in a hash' do
6971
hash = {}

0 commit comments

Comments
 (0)