ruby-lsp: RuboCop v1.70 incompatibilities and new RuboCop add-on

RuboCop v1.70 added an add-on to provide linting and formatting via the Ruby LSP. This is a great move long term, as it allows RuboCop maintainers to improve the integrations and ensure compatibility across versions.

Unfortunately, this first iteration of the add-on is conflicting with our internal integrations with RuboCop and may cause some issues. Namely, two things may happen:

  1. Namespace conflicts like #3044
  2. Linter registration conflicts since it’s using the same identifier as the one we use internally. This means that the LSP may end up using the add-on version and some features can potentially be missing or other features may break (like watching .rubocop.yml)

Transition plan

We need a transition plan since people will still rely on our internal integrations while they are upgrading RuboCop. It may take a while until the community catches up to the newest versions.

Steps

  • Decide identifier change. If we change ours from rubocop to rubocop_internal, it will avoid the conflict, but it also means that anyone who has configured to use rubocop will try to use the add-on. If the application is on an older version of RuboCop where the add-on is not available, that will fail and no formatting will be available. We can add logic to check for this scenario and try to do the right thing depending on what’s available
  • Our automatic detection for linters will need to change as well. We will now need to take the add-on into account if it’s available and then decide whether to use the internal or the add-on version
  • Map all feature differences between our internal integrations and the RuboCop add-on, so that we can ensure feature completeness for the community

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 23 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@vinistock Thank you for considering the migration plan for Ruby LSP.

Ideally, in the future, it would be great if Ruby LSP could replace its dependency on RuboCop’s internal APIs with RuboCop’s Ruby LSP add-on. Interacting through only published interface is crucial for good design 😃

Ideally, Ruby LSP should focus solely on LSP functionality. It would be ideal if Ruby LSP no longer needed to know the internal implementation of RuboCop’s Linter/Formatter, allowing each module to concentrate on its intended role. I hope my understanding aligns with what you previously conveyed.

That said, while the Ruby LSP add-on released with RuboCop 1.70 is honestly still insufficient to replace Ruby LSP’s existing RuboCop dependency, I hope this serves as a starting point to gradually evolve the Ruby toolchain ecosystem toward its ideal form. Thank you.

@1990eam those warnings are not relevant, it’s just because the LSP sets up the bundle on its own and Bundler emits some of these messages.

Your problem seems to be the rbs version constraining the update for the Ruby LSP, as described in the docs.

We depend on rbs >= 3 and your bundle seems to be locked to rbs v2.8.4.

You have to ensure that you can update rbs to 3 or higher so that the LSP can auto upgrade too. If you have another dependency constraining the version of rbs to be lower than 3, than that’s the thing preventing the upgrades.

@bradsb please check your Bundler version is up-to-date. IIRC some older versions had problem with resolving to incorrect sources.

Hi @vinistock thanks for the fixes. Do you know when the update will be available for VsCode?

Yes, I agree. Having RuboCop control the integrations allows for the LSP integration and internal API to evolve side by side, which opens up the possibility for more complex changes.

I created https://github.com/Shopify/ruby-lsp/pull/3067, which addresses the first two points related to the formatter identifier conflict.

Now, we just need to map if there are any feature differences to make the add-on match our internal integration. And, of course, keep the internal integration for a while since people on RuboCop < 1.70 will still need it.

No longer necessary after #3045. It seems like things are working normally, although we still need to iron out the remaining details. I updated my comment on the RuboCop PR.

v0.23.5 has the fix.