Skip to content

Configure Ruby LSP to use Standard for formatting and linting - #6161

Open
TonyCTHsu wants to merge 1 commit into
masterfrom
fix/vscode-ruby-lsp-standard-formatter
Open

Configure Ruby LSP to use Standard for formatting and linting#6161
TonyCTHsu wants to merge 1 commit into
masterfrom
fix/vscode-ruby-lsp-standard-formatter

Conversation

@TonyCTHsu

Copy link
Copy Markdown
Collaborator

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 rubocop dependency, which we have for our custom cops. That leaves in-editor formatting out of sync with rake 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 standardrb output.

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).
@TonyCTHsu TonyCTHsu added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Aug 6, 2026
@TonyCTHsu
TonyCTHsu requested a review from a team as a code owner August 6, 2026 09:56
@TonyCTHsu TonyCTHsu added the dev/tooling Involves tools (e.g. Rubocop, CodeCov) label Aug 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .vscode/settings.json
Comment on lines +7 to +8
"rubyLsp.formatter": "standard",
"rubyLsp.linters": ["standard"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a fair point

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 90.03% (-0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ef7f0e5 | Docs | Datadog PR Page | Give us feedback!

@lloeki lloeki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos dev/tooling Involves tools (e.g. Rubocop, CodeCov)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants