Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of support AutoCorrect: contextual option for LSP #1905

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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