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

We also need support AutoCorrect: contextual option for LSP #1883

Closed
ydah opened this issue May 19, 2024 · 5 comments · Fixed by #1899
Closed

We also need support AutoCorrect: contextual option for LSP #1883

ydah opened this issue May 19, 2024 · 5 comments · Fixed by #1899
Assignees
Milestone

Comments

@ydah
Copy link
Member

ydah commented May 19, 2024

For example, if RSpec/Focus is enabled, we will always have focus removed by the LSP.
https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfocus

@ydah ydah self-assigned this May 19, 2024
@ydah ydah added this to the 3.0 milestone May 19, 2024
@bquorning
Copy link
Collaborator

bquorning commented May 20, 2024

As far as I can tell, this is the current state of autocorrection for the different cops, sorted by “Always”, “Always (unsafe)”, “No”:

Always

  • RSpec/AlignLeftLetBrace
  • RSpec/AlignRightLetBrace
  • RSpec/BeEmpty
  • RSpec/BeNil
  • RSpec/ChangeByZero
  • RSpec/ClassCheck
  • RSpec/ContainExactly
  • RSpec/ContextMethod
  • RSpec/Dialect
  • RSpec/DuplicatedMetadata
  • RSpec/EmptyHook
  • RSpec/EmptyLineAfterExample
  • RSpec/EmptyLineAfterExampleGroup
  • RSpec/EmptyLineAfterFinalLet
  • RSpec/EmptyLineAfterHook
  • RSpec/EmptyLineAfterSubject
  • RSpec/EmptyMetadata
  • RSpec/EmptyOutput
  • RSpec/Eq
  • RSpec/ExampleWording
  • RSpec/ExcessiveDocstringSpacing
  • RSpec/ExpectActual
  • RSpec/Focus
  • RSpec/HookArgument
  • RSpec/HooksBeforeExamples
  • RSpec/ImplicitExpect
  • RSpec/ImplicitSubject
  • RSpec/InstanceSpy
  • RSpec/IsExpectedSpecify
  • RSpec/ItBehavesLike
  • RSpec/LeadingSubject
  • RSpec/LetBeforeExamples
  • RSpec/MatchArray
  • RSpec/MetadataStyle
  • RSpec/MultipleSubjects
  • RSpec/NotToNot
  • RSpec/ReceiveCounts
  • RSpec/ReceiveNever
  • RSpec/RedundantAround
  • RSpec/RedundantPredicateMatcher
  • RSpec/ReturnFromStub
  • RSpec/ScatteredLet
  • RSpec/ScatteredSetup
  • RSpec/SharedContext
  • RSpec/SharedExamples
  • RSpec/SingleArgumentMessageChain
  • RSpec/SortMetadata
  • RSpec/VariableDefinition
  • RSpec/Yield

Always (Unsafe)

  • RSpec/BeEq
  • RSpec/BeEql
  • RSpec/DescribedClass
  • RSpec/EmptyExampleGroup
  • RSpec/ExpectChange
  • RSpec/PredicateMatcher
  • RSpec/ReceiveMessages
  • RSpec/VerifiedDoubleReference

No

  • RSpec/AnyInstance
  • RSpec/AroundBlock
  • RSpec/Be
  • RSpec/BeforeAfterAll
  • RSpec/ContextWording
  • RSpec/DescribeClass
  • RSpec/DescribedClassModuleWrapping
  • RSpec/DescribeMethod
  • RSpec/DescribeSymbol
  • RSpec/ExampleLength
  • RSpec/ExampleWithoutDescription
  • RSpec/ExpectInHook
  • RSpec/ExpectOutput
  • RSpec/IdenticalEqualityAssertion
  • RSpec/ImplicitBlockExpectation
  • RSpec/IndexedLet
  • RSpec/InstanceVariable
  • RSpec/IteratedExpectation
  • RSpec/LeakyConstantDeclaration
  • RSpec/LetSetup
  • RSpec/MessageChain
  • RSpec/MessageExpectation
  • RSpec/MessageSpies
  • RSpec/MissingExampleGroupArgument
  • RSpec/MultipleDescribes
  • RSpec/MultipleExpectations
  • RSpec/MultipleMemoizedHelpers
  • RSpec/NamedSubject
  • RSpec/NestedGroups
  • RSpec/NoExpectationExample
  • RSpec/OverwritingSetup
  • RSpec/Pending
  • RSpec/PendingWithoutReason
  • RSpec/RemoveConst
  • RSpec/RepeatedDescription
  • RSpec/RepeatedExample
  • RSpec/RepeatedExampleGroupBody
  • RSpec/RepeatedExampleGroupDescription
  • RSpec/RepeatedIncludeExample
  • RSpec/RepeatedSubjectCall
  • RSpec/SkipBlockInsideExample
  • RSpec/SpecFilePathFormat
  • RSpec/SpecFilePathSuffix
  • RSpec/StubbedMock
  • RSpec/SubjectDeclaration
  • RSpec/SubjectStub
  • RSpec/UndescriptiveLiteralsDescription
  • RSpec/UnspecifiedException
  • RSpec/VariableName
  • RSpec/VerifiedDoubles
  • RSpec/VoidExpect

Should we start listing which ones we want to be contextual?

@ydah
Copy link
Member Author

ydah commented May 20, 2024

Basically, I think always is fine. So, let's list only the obvious annoyances like RSpec/Focus as a contextual list. If the cop that requires contextual is not contextual, it doesn't break the existing behavior. WDYT?

@bquorning
Copy link
Collaborator

What about cops like RSpec/ScatteredLet and RSpec/ScatteredSetup, wouldn’t they potentially move the code a person is currently editing?

@bquorning
Copy link
Collaborator

bquorning commented May 20, 2024

Hold on, when are LSP corrections applied? Only when a file is saved, right?

rubocop/rubocop#12657 says

This PR introduces AutoCorrect: contextual option that prevents autocorrection during typing in LSP.

which seems to suggest corrections are applied before saving, while still typing.

@ydah
Copy link
Member Author

ydah commented May 24, 2024

I think the automatic correction is done when saving to a file. I think the following Finish Editing is what happens when you save a file:
https://speakerdeck.com/koic/rubocop-lsp-and-prism?slide=62

@ydah ydah mentioned this issue Jun 3, 2024
6 tasks
ydah added a commit that referenced this issue Jun 3, 2024
ydah added a commit that referenced this issue Jun 3, 2024
@ydah ydah closed this as completed in #1899 Jun 3, 2024
ydah added a commit that referenced this issue Jun 5, 2024
ydah added a commit that referenced this issue Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants