Skip to content

Commit

Permalink
Support AutoCorrect: contextual option for LSP
Browse files Browse the repository at this point in the history
Fix: #1883
  • Loading branch information
ydah committed Jun 3, 2024
1 parent 345aa84 commit b9d3918
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Remove `RSpec/FilePath` cop. ([@ydah])
- Add new `RSpec/ExpectInLet` cop. ([@yasu551])
- Remove `RSpec/Capybara/FeatureMethods` cop. If you are using this cop, change it to use `RSpec/Dialect`. ([@ydah])
- Support `AutoCorrect: contextual` option for LSP. ([@ydah])

## 2.29.2 (2024-05-02)

Expand Down
22 changes: 18 additions & 4 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ RSpec/Be:
RSpec/BeEmpty:
Description: Prefer using `be_empty` when checking for an empty array.
Enabled: pending
AutoCorrect: contextual
VersionAdded: '2.20'
VersionChanged: "<<next>>"
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/BeEmpty

RSpec/BeEq:
Expand Down Expand Up @@ -311,15 +313,18 @@ RSpec/DuplicatedMetadata:
RSpec/EmptyExampleGroup:
Description: Checks if an example group does not include any tests.
Enabled: true
AutoCorrect: contextual
SafeAutoCorrect: false
VersionAdded: '1.7'
VersionChanged: '2.13'
VersionChanged: "<<next>>"
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyExampleGroup

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

RSpec/EmptyLineAfterExample:
Expand Down Expand Up @@ -363,7 +368,9 @@ RSpec/EmptyLineAfterSubject:
RSpec/EmptyMetadata:
Description: Avoid empty metadata hash.
Enabled: pending
AutoCorrect: contextual
VersionAdded: '2.24'
VersionChanged: "<<next>>"
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyMetadata

RSpec/EmptyOutput:
Expand Down Expand Up @@ -462,8 +469,9 @@ RSpec/ExpectOutput:
RSpec/Focus:
Description: Checks if examples are focused.
Enabled: true
AutoCorrect: contextual
VersionAdded: '1.5'
VersionChanged: '2.1'
VersionChanged: "<<next>>"
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Focus

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

RSpec/IdenticalEqualityAssertion:
Expand Down Expand Up @@ -587,8 +597,9 @@ RSpec/LeakyConstantDeclaration:
RSpec/LetBeforeExamples:
Description: Checks for `let` definitions that come after an example.
Enabled: true
AutoCorrect: contextual
VersionAdded: '1.16'
VersionChanged: '1.22'
VersionChanged: "<<next>>"
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples

RSpec/LetSetup:
Expand Down Expand Up @@ -838,14 +849,17 @@ RSpec/ReturnFromStub:
RSpec/ScatteredLet:
Description: Checks for let scattered across the example group.
Enabled: true
AutoCorrect: contextual
VersionAdded: '1.14'
VersionChanged: '1.39'
VersionChanged: "<<next>>"
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet

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

RSpec/SharedContext:
Expand Down
36 changes: 18 additions & 18 deletions docs/modules/ROOT/pages/cops_rspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ expect(foo).to be(true)
| Pending
| Yes
| Always
| Command-line only
| 2.20
| -
| <<next>>
|===
Prefer using `be_empty` when checking for an empty array.
Expand Down Expand Up @@ -1153,9 +1153,9 @@ describe 'Something', :a
| Enabled
| Yes
| Always (Unsafe)
| Command-line only (Unsafe)
| 1.7
| 2.13
| <<next>>
|===
Checks if an example group does not include any tests.
Expand Down Expand Up @@ -1207,9 +1207,9 @@ end
| Enabled
| Yes
| Always
| Command-line only
| 1.39
| -
| <<next>>
|===
Checks for empty before and after hooks.
Expand Down Expand Up @@ -1510,9 +1510,9 @@ let(:foo) { bar }
| Pending
| Yes
| Always
| Command-line only
| 2.24
| -
| <<next>>
|===
Avoid empty metadata hash.
Expand Down Expand Up @@ -2127,9 +2127,9 @@ expect { my_app.print_report }.to output('Hello World').to_stdout
| Enabled
| Yes
| Always
| Command-line only
| 1.5
| 2.1
| <<next>>
|===
Checks if examples are focused.
Expand Down Expand Up @@ -2289,9 +2289,9 @@ end
| Enabled
| Yes
| Always
| Command-line only
| 1.29
| -
| <<next>>
|===
Checks for before/around/after hooks that come after an example.
Expand Down Expand Up @@ -3044,9 +3044,9 @@ end
| Enabled
| Yes
| Always
| Command-line only
| 1.16
| 1.22
| <<next>>
|===
Checks for `let` definitions that come after an example.
Expand Down Expand Up @@ -5000,9 +5000,9 @@ allow(Foo).to receive(:bar).and_return(bar.baz)
| Enabled
| Yes
| Always
| Command-line only
| 1.14
| 1.39
| <<next>>
|===
Checks for let scattered across the example group.
Expand Down Expand Up @@ -5043,9 +5043,9 @@ end
| Enabled
| Yes
| Always
| Command-line only
| 1.10
| -
| <<next>>
|===
Checks for setup scattered across multiple hooks in an example group.
Expand Down

0 comments on commit b9d3918

Please sign in to comment.