Skip to content

Commit 494de00

Browse files
authored
Merge pull request #1410 from rubocop/bquorning.enable-some-new-cops
Enable some new cops
2 parents 4a05fd3 + 7b5b940 commit 494de00

17 files changed

+64
-56
lines changed

.rubocop.yml

+9
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ Style/FormatStringToken:
9595
Exclude:
9696
- spec/rubocop/**/*.rb
9797

98+
# Enable some of RuboCop's pending cops.
99+
100+
Layout/LineContinuationSpacing:
101+
Enabled: true
102+
Layout/LineEndStringConcatenationIndentation:
103+
Enabled: true
104+
Style/EmptyHeredoc:
105+
Enabled: true
106+
98107
# Enable our own pending cops.
99108

100109
RSpec/BeEq:

lib/rubocop/cop/rspec/change_by_zero.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ChangeByZero < Base
6161
extend AutoCorrector
6262
MSG = 'Prefer `not_to change` over `to change.by(0)`.'
6363
MSG_COMPOUND = 'Prefer %<preferred>s with compound expectations ' \
64-
'over `change.by(0)`.'
64+
'over `change.by(0)`.'
6565
RESTRICT_ON_SEND = %i[change].freeze
6666

6767
# @!method expect_change_with_arguments(node)

lib/rubocop/cop/rspec/factory_bot/create_list.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def format_multiline_block(node)
238238
indent = ' ' * node.body.loc.column
239239
indent_end = ' ' * node.parent.loc.column
240240
" do #{node.arguments.source}\n" \
241-
"#{indent}#{node.body.source}\n" \
242-
"#{indent_end}end"
241+
"#{indent}#{node.body.source}\n" \
242+
"#{indent_end}end"
243243
end
244244

245245
def format_singleline_block(node)

lib/rubocop/cop/rspec/repeated_include_example.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module RSpec
4747
#
4848
class RepeatedIncludeExample < Base
4949
MSG = 'Repeated include of shared_examples %<name>s ' \
50-
'on line(s) %<repeat>s'
50+
'on line(s) %<repeat>s'
5151

5252
# @!method several_include_examples?(node)
5353
def_node_matcher :several_include_examples?, <<-PATTERN

spec/rubocop/cli/autocorrect_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
include_context 'when cli spec behavior'
99

1010
context 'when corrects `RSpec/Capybara/CurrentPathExpectation` with ' \
11-
'`Style/TrailingCommaInArguments`' do
11+
'`Style/TrailingCommaInArguments`' do
1212
before do
1313
RuboCop::ConfigLoader
1414
.default_configuration

spec/rubocop/cop/rspec/before_after_all_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll do
44
def message(hook)
55
"Beware of using `#{hook}` as it may cause state to leak between tests. " \
6-
'If you are using `rspec-rails`, and `use_transactional_fixtures` is ' \
7-
"enabled, then records created in `#{hook}` are not automatically rolled " \
8-
'back.'
6+
'If you are using `rspec-rails`, and `use_transactional_fixtures` is ' \
7+
"enabled, then records created in `#{hook}` are not automatically " \
8+
'rolled back.'
99
end
1010

1111
context 'when using before all' do

spec/rubocop/cop/rspec/capybara/specific_finders_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
end
3636

3737
it 'registers an offense when using `find` and other args ' \
38-
'with no parentheses' do
38+
'with no parentheses' do
3939
expect_offense(<<~RUBY)
4040
find '#some-id', exact_text: 'foo'
4141
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `find_by` over `find`.
@@ -60,7 +60,7 @@
6060
end
6161

6262
it 'registers an offense when using `find ' \
63-
'with argument is attribute specified id' do
63+
'with argument is attribute specified id' do
6464
expect_offense(<<~RUBY)
6565
find('[id=some-id]')
6666
^^^^^^^^^^^^^^^^^^^^ Prefer `find_by` over `find`.
@@ -78,29 +78,29 @@
7878
end
7979

8080
it 'does not register an offense when using `find ' \
81-
'with argument is attribute not specified id' do
81+
'with argument is attribute not specified id' do
8282
expect_no_offenses(<<~RUBY)
8383
find('[visible]')
8484
find('[class=some-cls][visible]')
8585
RUBY
8686
end
8787

8888
it 'does not register an offense when using `find ' \
89-
'with argument is element with id' do
89+
'with argument is element with id' do
9090
expect_no_offenses(<<~RUBY)
9191
find('h1#some-id')
9292
RUBY
9393
end
9494

9595
it 'does not register an offense when using `find ' \
96-
'with argument is element with attribute specified id' do
96+
'with argument is element with attribute specified id' do
9797
expect_no_offenses(<<~RUBY)
9898
find('h1[id=some-id]')
9999
RUBY
100100
end
101101

102102
it 'does not register an offense when using `find` ' \
103-
'with argument is not id' do
103+
'with argument is not id' do
104104
expect_no_offenses(<<~RUBY)
105105
find('a.some-id')
106106
find('.some-id')
@@ -114,7 +114,7 @@
114114
end
115115

116116
it 'does not register an offense when using `find` ' \
117-
'with argument is id with multiple matcher' do
117+
'with argument is id with multiple matcher' do
118118
expect_no_offenses(<<~RUBY)
119119
find('#some-id body')
120120
find('#some-id>h1')

spec/rubocop/cop/rspec/capybara/specific_matcher_spec.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
RSpec.describe RuboCop::Cop::RSpec::Capybara::SpecificMatcher do
44
it 'does not register an offense for abstract matcher when ' \
5-
'first argument is not a replaceable element' do
5+
'first argument is not a replaceable element' do
66
expect_no_offenses(<<-RUBY)
77
expect(page).to have_selector('article')
88
expect(page).to have_no_selector('body')
@@ -11,7 +11,7 @@
1111
end
1212

1313
it 'does not register an offense for abstract matcher when ' \
14-
'first argument is not an element' do
14+
'first argument is not an element' do
1515
expect_no_offenses(<<-RUBY)
1616
expect(page).to have_no_css('.a')
1717
expect(page).to have_selector('#button')
@@ -206,7 +206,7 @@ class style visible obscured exact exact_text normalize_ws match wait
206206
end
207207

208208
it 'registers an offense when using abstract matcher with ' \
209-
'first argument is element with replaceable pseudo-classes' do
209+
'first argument is element with replaceable pseudo-classes' do
210210
expect_offense(<<-RUBY)
211211
expect(page).to have_css('button:not([disabled])', exact_text: 'bar')
212212
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `have_button` over `have_css`.
@@ -216,7 +216,7 @@ class style visible obscured exact exact_text normalize_ws match wait
216216
end
217217

218218
it 'registers an offense when using abstract matcher with ' \
219-
'first argument is element with multiple replaceable pseudo-classes' do
219+
'first argument is element with multiple replaceable pseudo-classes' do
220220
expect_offense(<<-RUBY)
221221
expect(page).to have_css('button:not([disabled]):enabled')
222222
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `have_button` over `have_css`.
@@ -234,22 +234,22 @@ class style visible obscured exact exact_text normalize_ws match wait
234234
end
235235

236236
it 'does not register an offense when using abstract matcher with ' \
237-
'first argument is element with replaceable pseudo-classes' \
238-
'and not boolean attributes' do
237+
'first argument is element with replaceable pseudo-classes' \
238+
'and not boolean attributes' do
239239
expect_no_offenses(<<-RUBY)
240240
expect(page).to have_css('button:not([name="foo"][disabled])')
241241
RUBY
242242
end
243243

244244
it 'does not register an offense when using abstract matcher with ' \
245-
'first argument is element with multiple nonreplaceable pseudo-classes' do
245+
'first argument is element with multiple nonreplaceable pseudo-classes' do
246246
expect_no_offenses(<<-RUBY)
247247
expect(page).to have_css('button:first-of-type:not([disabled])')
248248
RUBY
249249
end
250250

251251
it 'does not register an offense for abstract matcher when ' \
252-
'first argument is element with nonreplaceable attributes' do
252+
'first argument is element with nonreplaceable attributes' do
253253
expect_no_offenses(<<-RUBY)
254254
expect(page).to have_css('button[data-disabled]')
255255
expect(page).to have_css('button[foo=bar]')
@@ -258,7 +258,7 @@ class style visible obscured exact exact_text normalize_ws match wait
258258
end
259259

260260
it 'does not register an offense for abstract matcher when ' \
261-
'first argument is element with multiple nonreplaceable attributes' do
261+
'first argument is element with multiple nonreplaceable attributes' do
262262
expect_no_offenses(<<-RUBY)
263263
expect(page).to have_css('button[disabled][foo]')
264264
expect(page).to have_css('button[foo][disabled]')
@@ -269,7 +269,7 @@ class style visible obscured exact exact_text normalize_ws match wait
269269
end
270270

271271
it 'does not register an offense for abstract matcher when ' \
272-
'first argument is element with sub matcher' do
272+
'first argument is element with sub matcher' do
273273
expect_no_offenses(<<-RUBY)
274274
expect(page).to have_css('button body')
275275
expect(page).to have_css('a,h1')
@@ -279,7 +279,7 @@ class style visible obscured exact exact_text normalize_ws match wait
279279
end
280280

281281
it 'does not register an offense for abstract matcher when ' \
282-
'first argument is dstr' do
282+
'first argument is dstr' do
283283
expect_no_offenses(<<-'RUBY')
284284
expect(page).to have_css(%{a[href="#{foo}"]}, text: "bar")
285285
RUBY

spec/rubocop/cop/rspec/change_by_zero_spec.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
context 'when `NegatedMatcher` is not defined (default)' do
2929
it 'registers an offense when the argument to `by` is zero ' \
30-
'with compound expectations by `and`' do
30+
'with compound expectations by `and`' do
3131
expect_offense(<<-RUBY)
3232
it do
3333
expect { foo }.to change(Foo, :bar).by(0).and change(Foo, :baz).by(0)
@@ -43,7 +43,7 @@
4343
end
4444

4545
it 'registers an offense when the argument to `by` is zero ' \
46-
'with compound expectations by `&`' do
46+
'with compound expectations by `&`' do
4747
expect_offense(<<-RUBY)
4848
it do
4949
expect { foo }.to change(Foo, :bar).by(0) & change(Foo, :baz).by(0)
@@ -59,7 +59,7 @@
5959
end
6060

6161
it 'registers an offense when the argument to `by` is zero ' \
62-
'with compound expectations by `or`' do
62+
'with compound expectations by `or`' do
6363
expect_offense(<<-RUBY)
6464
it do
6565
expect { foo }.to change(Foo, :bar).by(0).or change(Foo, :baz).by(0)
@@ -75,7 +75,7 @@
7575
end
7676

7777
it 'registers an offense when the argument to `by` is zero ' \
78-
'with compound expectations by `|`' do
78+
'with compound expectations by `|`' do
7979
expect_offense(<<-RUBY)
8080
it do
8181
expect { foo }.to change(Foo, :bar).by(0) | change(Foo, :baz).by(0)
@@ -92,7 +92,7 @@
9292

9393
context 'when with a line break' do
9494
it 'registers an offense when the argument to `by` is zero ' \
95-
'with compound expectations by `and`' do
95+
'with compound expectations by `and`' do
9696
expect_offense(<<-RUBY)
9797
it do
9898
expect { foo }
@@ -112,7 +112,7 @@
112112
end
113113

114114
it 'registers an offense when the argument to `by` is zero ' \
115-
'with compound expectations by `&`' do
115+
'with compound expectations by `&`' do
116116
expect_offense(<<-RUBY)
117117
it do
118118
expect { foo }
@@ -132,7 +132,7 @@
132132
end
133133

134134
it 'registers an offense when the argument to `by` is zero ' \
135-
'with compound expectations by `or`' do
135+
'with compound expectations by `or`' do
136136
expect_offense(<<-RUBY)
137137
it do
138138
expect { foo }
@@ -152,7 +152,7 @@
152152
end
153153

154154
it 'registers an offense when the argument to `by` is zero ' \
155-
'with compound expectations by `|`' do
155+
'with compound expectations by `|`' do
156156
expect_offense(<<-RUBY)
157157
it do
158158
expect { foo }
@@ -177,7 +177,7 @@
177177
let(:cop_config) { { 'NegatedMatcher' => 'not_change' } }
178178

179179
it 'registers an offense and autocorrect when ' \
180-
'the argument to `by` is zero with compound expectations' do
180+
'the argument to `by` is zero with compound expectations' do
181181
expect_offense(<<-RUBY)
182182
it do
183183
expect { foo }.to change(Foo, :bar).by(0).and change(Foo, :baz).by(0)
@@ -198,8 +198,8 @@
198198
end
199199

200200
it 'registers an offense and autocorrect when ' \
201-
'the argument to `by` is zero with compound expectations ' \
202-
'with line break' do
201+
'the argument to `by` is zero with compound expectations ' \
202+
'with line break' do
203203
expect_offense(<<-RUBY)
204204
it do
205205
expect { foo }

spec/rubocop/cop/rspec/empty_example_group_spec.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
end
4242
RUBY
4343

44-
expect_correction(<<~RUBY)
45-
RUBY
44+
expect_correction('')
4645
end
4746

4847
it 'flags example group with examples defined in hooks' do
@@ -160,7 +159,7 @@
160159
end
161160

162161
it 'flags an empty example group with no examples defined in `case`' \
163-
'branches' do
162+
'branches' do
164163
expect_offense(<<~RUBY)
165164
describe Foo do
166165
^^^^^^^^^^^^ Empty example group detected.

spec/rubocop/cop/rspec/empty_line_after_example_group_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@
232232
RUBY
233233
end
234234

235-
it 'flags a missing empty line after a `rubocop:enable` directive '\
236-
'when it is followed by a `rubocop:disable` directive' do
235+
it 'flags a missing empty line after a `rubocop:enable` directive ' \
236+
'when it is followed by a `rubocop:disable` directive' do
237237
expect_offense(<<-RUBY)
238238
RSpec.describe Foo do
239239
# rubocop:disable RSpec/Foo

spec/rubocop/cop/rspec/empty_line_after_example_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@
216216
RUBY
217217
end
218218

219-
it 'flags a missing empty line after a `rubocop:enable` directive '\
220-
'when it is followed by a `rubocop:disable` directive' do
219+
it 'flags a missing empty line after a `rubocop:enable` directive ' \
220+
'when it is followed by a `rubocop:disable` directive' do
221221
expect_offense(<<-RUBY)
222222
RSpec.describe Foo do
223223
# rubocop:disable RSpec/Foo

spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
RUBY
7777
end
7878

79-
it 'does not register an offense for comment '\
79+
it 'does not register an offense for comment ' \
8080
'followed by an empty line after let' do
8181
expect_no_offenses(<<-RUBY)
8282
RSpec.describe User do
@@ -183,8 +183,8 @@
183183
RUBY
184184
end
185185

186-
it 'flags a missing empty line after a `rubocop:enable` directive '\
187-
'when it is followed by a `rubocop:disable` directive' do
186+
it 'flags a missing empty line after a `rubocop:enable` directive ' \
187+
'when it is followed by a `rubocop:disable` directive' do
188188
expect_offense(<<-RUBY)
189189
RSpec.describe User do
190190
# rubocop:disable RSpec/Foo

spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@
253253
RUBY
254254
end
255255

256-
it 'flags a missing empty line after a `rubocop:enable` directive '\
257-
'when it is followed by a `rubocop:disable` directive' do
256+
it 'flags a missing empty line after a `rubocop:enable` directive ' \
257+
'when it is followed by a `rubocop:disable` directive' do
258258
expect_offense(<<-RUBY)
259259
RSpec.describe User do
260260
# rubocop:disable RSpec/Foo

spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@
183183
RUBY
184184
end
185185

186-
it 'flags a missing empty line after a `rubocop:enable` directive '\
187-
'when it is followed by a `rubocop:disable` directive' do
186+
it 'flags a missing empty line after a `rubocop:enable` directive ' \
187+
'when it is followed by a `rubocop:disable` directive' do
188188
expect_offense(<<-RUBY)
189189
RSpec.describe User do
190190
# rubocop:disable RSpec/Foo

0 commit comments

Comments
 (0)