Skip to content

Commit

Permalink
Merge pull request #1905 from rubocop/backport
Browse files Browse the repository at this point in the history
Backport of support `AutoCorrect: contextual` option for LSP
  • Loading branch information
ydah authored Jun 5, 2024
2 parents 0dec2d2 + 87aec85 commit 2b69a04
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Master (Unreleased)

- Support `AutoCorrect: contextual` option for LSP. ([@ydah])

## 2.30.0 (2024-06-03)

- Add new `RSpec/ExpectInLet` cop. ([@yasu551])
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 @@ -477,8 +484,9 @@ RSpec/FilePath:
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 @@ -496,7 +504,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 @@ -602,8 +612,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 @@ -853,14 +864,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 @@ -1140,9 +1140,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 @@ -1194,9 +1194,9 @@ end
| Enabled
| Yes
| Always
| Command-line only
| 1.39
| -
| <<next>>
|===
Checks for empty before and after hooks.
Expand Down Expand Up @@ -1497,9 +1497,9 @@ let(:foo) { bar }
| Pending
| Yes
| Always
| Command-line only
| 2.24
| -
| <<next>>
|===
Avoid empty metadata hash.
Expand Down Expand Up @@ -2223,9 +2223,9 @@ my_class_spec.rb # describe MyClass, '#method'
| Enabled
| Yes
| Always
| Command-line only
| 1.5
| 2.1
| <<next>>
|===
Checks if examples are focused.
Expand Down Expand Up @@ -2385,9 +2385,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 @@ -3140,9 +3140,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 @@ -5096,9 +5096,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 @@ -5139,9 +5139,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 2b69a04

Please sign in to comment.