Skip to content

Commit e49f221

Browse files
authored
Merge pull request #1899 from rubocop/support-contextual
Support `AutoCorrect: contextual` option for LSP
2 parents 345aa84 + b9d3918 commit e49f221

File tree

3 files changed

+37
-22
lines changed

3 files changed

+37
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Remove `RSpec/FilePath` cop. ([@ydah])
88
- Add new `RSpec/ExpectInLet` cop. ([@yasu551])
99
- Remove `RSpec/Capybara/FeatureMethods` cop. If you are using this cop, change it to use `RSpec/Dialect`. ([@ydah])
10+
- Support `AutoCorrect: contextual` option for LSP. ([@ydah])
1011

1112
## 2.29.2 (2024-05-02)
1213

config/default.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ RSpec/Be:
147147
RSpec/BeEmpty:
148148
Description: Prefer using `be_empty` when checking for an empty array.
149149
Enabled: pending
150+
AutoCorrect: contextual
150151
VersionAdded: '2.20'
152+
VersionChanged: "<<next>>"
151153
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEmpty
152154

153155
RSpec/BeEq:
@@ -311,15 +313,18 @@ RSpec/DuplicatedMetadata:
311313
RSpec/EmptyExampleGroup:
312314
Description: Checks if an example group does not include any tests.
313315
Enabled: true
316+
AutoCorrect: contextual
314317
SafeAutoCorrect: false
315318
VersionAdded: '1.7'
316-
VersionChanged: '2.13'
319+
VersionChanged: "<<next>>"
317320
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup
318321

319322
RSpec/EmptyHook:
320323
Description: Checks for empty before and after hooks.
321324
Enabled: true
325+
AutoCorrect: contextual
322326
VersionAdded: '1.39'
327+
VersionChanged: "<<next>>"
323328
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyHook
324329

325330
RSpec/EmptyLineAfterExample:
@@ -363,7 +368,9 @@ RSpec/EmptyLineAfterSubject:
363368
RSpec/EmptyMetadata:
364369
Description: Avoid empty metadata hash.
365370
Enabled: pending
371+
AutoCorrect: contextual
366372
VersionAdded: '2.24'
373+
VersionChanged: "<<next>>"
367374
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyMetadata
368375

369376
RSpec/EmptyOutput:
@@ -462,8 +469,9 @@ RSpec/ExpectOutput:
462469
RSpec/Focus:
463470
Description: Checks if examples are focused.
464471
Enabled: true
472+
AutoCorrect: contextual
465473
VersionAdded: '1.5'
466-
VersionChanged: '2.1'
474+
VersionChanged: "<<next>>"
467475
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Focus
468476

469477
RSpec/HookArgument:
@@ -481,7 +489,9 @@ RSpec/HookArgument:
481489
RSpec/HooksBeforeExamples:
482490
Description: Checks for before/around/after hooks that come after an example.
483491
Enabled: true
492+
AutoCorrect: contextual
484493
VersionAdded: '1.29'
494+
VersionChanged: "<<next>>"
485495
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
486496

487497
RSpec/IdenticalEqualityAssertion:
@@ -587,8 +597,9 @@ RSpec/LeakyConstantDeclaration:
587597
RSpec/LetBeforeExamples:
588598
Description: Checks for `let` definitions that come after an example.
589599
Enabled: true
600+
AutoCorrect: contextual
590601
VersionAdded: '1.16'
591-
VersionChanged: '1.22'
602+
VersionChanged: "<<next>>"
592603
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples
593604

594605
RSpec/LetSetup:
@@ -838,14 +849,17 @@ RSpec/ReturnFromStub:
838849
RSpec/ScatteredLet:
839850
Description: Checks for let scattered across the example group.
840851
Enabled: true
852+
AutoCorrect: contextual
841853
VersionAdded: '1.14'
842-
VersionChanged: '1.39'
854+
VersionChanged: "<<next>>"
843855
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
844856

845857
RSpec/ScatteredSetup:
846858
Description: Checks for setup scattered across multiple hooks in an example group.
847859
Enabled: true
860+
AutoCorrect: contextual
848861
VersionAdded: '1.10'
862+
VersionChanged: "<<next>>"
849863
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
850864

851865
RSpec/SharedContext:

docs/modules/ROOT/pages/cops_rspec.adoc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ expect(foo).to be(true)
199199
200200
| Pending
201201
| Yes
202-
| Always
202+
| Command-line only
203203
| 2.20
204-
| -
204+
| <<next>>
205205
|===
206206
207207
Prefer using `be_empty` when checking for an empty array.
@@ -1153,9 +1153,9 @@ describe 'Something', :a
11531153
11541154
| Enabled
11551155
| Yes
1156-
| Always (Unsafe)
1156+
| Command-line only (Unsafe)
11571157
| 1.7
1158-
| 2.13
1158+
| <<next>>
11591159
|===
11601160
11611161
Checks if an example group does not include any tests.
@@ -1207,9 +1207,9 @@ end
12071207
12081208
| Enabled
12091209
| Yes
1210-
| Always
1210+
| Command-line only
12111211
| 1.39
1212-
| -
1212+
| <<next>>
12131213
|===
12141214
12151215
Checks for empty before and after hooks.
@@ -1510,9 +1510,9 @@ let(:foo) { bar }
15101510
15111511
| Pending
15121512
| Yes
1513-
| Always
1513+
| Command-line only
15141514
| 2.24
1515-
| -
1515+
| <<next>>
15161516
|===
15171517
15181518
Avoid empty metadata hash.
@@ -2127,9 +2127,9 @@ expect { my_app.print_report }.to output('Hello World').to_stdout
21272127
21282128
| Enabled
21292129
| Yes
2130-
| Always
2130+
| Command-line only
21312131
| 1.5
2132-
| 2.1
2132+
| <<next>>
21332133
|===
21342134
21352135
Checks if examples are focused.
@@ -2289,9 +2289,9 @@ end
22892289
22902290
| Enabled
22912291
| Yes
2292-
| Always
2292+
| Command-line only
22932293
| 1.29
2294-
| -
2294+
| <<next>>
22952295
|===
22962296
22972297
Checks for before/around/after hooks that come after an example.
@@ -3044,9 +3044,9 @@ end
30443044
30453045
| Enabled
30463046
| Yes
3047-
| Always
3047+
| Command-line only
30483048
| 1.16
3049-
| 1.22
3049+
| <<next>>
30503050
|===
30513051
30523052
Checks for `let` definitions that come after an example.
@@ -5000,9 +5000,9 @@ allow(Foo).to receive(:bar).and_return(bar.baz)
50005000
50015001
| Enabled
50025002
| Yes
5003-
| Always
5003+
| Command-line only
50045004
| 1.14
5005-
| 1.39
5005+
| <<next>>
50065006
|===
50075007
50085008
Checks for let scattered across the example group.
@@ -5043,9 +5043,9 @@ end
50435043
50445044
| Enabled
50455045
| Yes
5046-
| Always
5046+
| Command-line only
50475047
| 1.10
5048-
| -
5048+
| <<next>>
50495049
|===
50505050
50515051
Checks for setup scattered across multiple hooks in an example group.

0 commit comments

Comments
 (0)