Configure Ruby LSP to use Standard for formatting and linting - #6161
Configure Ruby LSP to use Standard for formatting and linting#6161TonyCTHsu wants to merge 1 commit into
Conversation
Ruby LSP auto-detects rubocop_internal because rubocop is a direct dependency (needed for our custom cops), so it never picks up the Standard addon that standard already ships. This left VS Code's in-editor autocorrect diverging from rake standard (e.g. rewriting double-quoted strings that standardrb leaves alone).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef7f0e5424
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "rubyLsp.formatter": "standard", | ||
| "rubyLsp.linters": ["standard"] |
There was a problem hiding this comment.
Make Standard available to every Ruby LSP bundle
When VS Code runs Ruby LSP with Ruby 3.0–3.4, these explicit selections cannot load because those versions' gemfiles declare ruby-lsp but not standard; only gemfiles/ruby-4.0.gemfile includes Standard. Ruby LSP consequently disables the selected formatter and linter instead of matching rake standard, so this configuration breaks both editor features for developers using the repository's supported 3.x Rubies. Add a compatible Standard dependency to each Ruby LSP bundle or avoid selecting it where it is unavailable.
AGENTS.md reference: AGENTS.md:L5-L5
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
That is a fair point
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: ef7f0e5 | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
Ruby LSP defaults to RuboCop whenever it sees a direct rubocop dependency, which we have for our custom cops.
That leaves in-editor formatting out of sync with rake standard, our actual linter.
I'm not sure I understand this.
Since rubocop uses .rubocop.yml, which then uses the Standard ruleset, rubocop and standard (and their respective rake tasks) are in sync, albeit one being a subset of the other.
This is proven by CI running both rubocop -D and rake standard back to back.
standard, our actual linter.
standardrb and rake standard both run only the Standard ruleset as configured, so by definition lack rules that are enforced by rubocop only. The rubocop program is the only one that can run everything.
That leaves in-editor formatting out of sync
If it is out of sync I would suspect editor misconfiguration that leads to rubocop not picking up .rubocop.yml and/or not being executed via bundle exec.
our custom cops
I believe the custom cops we have in special config under rubocop/ and .customcops.yml should now be collapsed under the normal .rubocop.yml file, removing all manners of special casing.
What does this PR do?
Points VS Code's Ruby LSP at Standard instead of raw RuboCop.
Motivation:
Ruby LSP defaults to RuboCop whenever it sees a direct
rubocopdependency, which we have for our custom cops. That leaves in-editor formatting out of sync withrake standard, our actual linter.Change log entry
None.
Additional Notes:
None.
How to test the change?
Reload the Ruby LSP server in VS Code and confirm autocorrect matches
standardrboutput.