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

Support safe or unsafe autocorrect config for LSP #12000

Merged

Conversation

koic
Copy link
Member

@koic koic commented Jun 29, 2023

This PR supports safe or unsafe autocorrect config for LSP.

The autocorrection is still safe by default (rubocop -a).

LSP client can switch to unsafe autocorrection (rubocop -A) by passing the following safeAutocorrect parameter in the initialize request.

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "initialize",
  "params": {
    "initializationOptions": {
      "safeAutocorrect": false
    }
  }
}

Some users may want to set unsafe autocorrection as the default for the LSP, understanding the risks involved.

However, considering that the default should be safe, unsafe is an option.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@koic koic force-pushed the support_safe_autocorrect_config_for_lsp branch from d359d2a to 81d6d34 Compare June 29, 2023 15:47
This PR supports safe or unsafe autocorrect config for LSP.

The autocorrection is still safe by default (`rubocop -a`).

LSP client can switch to unsafe autocorrection (`rubocop -A`) by passing the following
`safeAutocorrect` parameter in the `initialize` request.

```json
{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "initialize",
  "params": {
    "initializationOptions": {
      "safeAutocorrect": false
    }
  }
}
```

Some users may want to set unsafe autocorrection as the default for the LSP,
understanding the risks involved.

However, considering that the default should be safe, unsafe is an option.
@koic koic force-pushed the support_safe_autocorrect_config_for_lsp branch from 81d6d34 to 19048c6 Compare June 29, 2023 15:59
@bbatsov bbatsov merged commit 7e8c47d into rubocop:master Jun 30, 2023
28 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 30, 2023

Nice improvement!

@koic koic deleted the support_safe_autocorrect_config_for_lsp branch June 30, 2023 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants