Skip to content

Upgrade to ruby-lsp 0.26 - #6

Merged
igray merged 2 commits into
mainfrom
ruby-lsp-0.26
Aug 1, 2026
Merged

Upgrade to ruby-lsp 0.26#6
igray merged 2 commits into
mainfrom
ruby-lsp-0.26

Conversation

@igray

@igray igray commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Points the gem at the latest stable ruby-lsp (0.26.10; 0.27 is still beta-only), drops the now-unused sorbet-runtime dependency, and clears the reek warnings so rake code_analysis passes.

ruby-lsp 0.26

  • ruby-lsp dependency ~> 0.17, >= 0.12.0~> 0.26, and required_ruby_version >= 2.5.0>= 3.0.0 to match what ruby-lsp actually requires.
  • Added Addon#version. Since 0.23 the base class treats it as abstract and uses it for the Addon.get(name, constraint) compatibility check, so without it any other addon querying this one blows up with AbstractMethodInvokedError.

Everything else in the addon survived the jump — register_formatter, run_diagnostic(uri, document), supports_watching_files and the file-watcher registration all have unchanged signatures.

The actual breakage was in the tests, which hand-rolled with_server against internals that no longer exist (core_ext/uri, RubyIndexer::IndexablePath). They now use the RubyLsp::TestHelper module ruby-lsp ships for addons, require ruby_lsp/internal instead of a long explicit require list, and use pop_result so notifications in the queue don't break assertions. The expected reek docs URL is interpolated from Reek::Version::STRING rather than hardcoded at v6.3.0.

Dropping sorbet-runtime

ruby-lsp 0.26 no longer depends on it, and the only reference left in this repo was a bare require "sorbet-runtime" — no T. or T::Sig usage anywhere. Removing it stops forcing the gem on consumers.

reek cleanup

rake code_analysis was failing on 3 warnings (pre-existing, unrelated to the upgrade):

  • FeatureEnvy in Runner#build_examiner — fixed by deleting the method. It existed to work around Reek::Examiner not accepting a separate source and origin, doing it via two instance_variable_set calls into reek internals. Reek::Source::SourceCode.from(source, origin:) takes an explicit origin and Examiner passes a SourceCode through untouched, so the workaround collapses to one line with no internals poking.
  • UtilityFunction in #warning_to_diagnostic — took reek's own suggestion and extracted it to Reek::Diagnostic.from_warning in a new file.
  • UtilityFunction in #run_formatting — not fixable. The Formatter interface mandates an instance method and reek is a linter, so there's nothing to format and no instance state to depend on. Suppressed in place with a comment explaining why, rather than a blanket .reek.yml rule.

Worth a look during review

build_examiner was the fix from #5 and had no test, so rewriting it would have been blind. Added test_diagnostic_resolves_directives_from_the_file_path, which builds a tmpdir with a .reek.yml directory directive and asserts a file under app/models is exempt while one under lib is not. Mutation-checked by dropping origin: — the test fails, so it's a real regression test.

Also note lib/ruby_lsp/reek/diagnostic.rb had to be git-tracked before it appeared in the built gem — spec.files comes from git ls-files, so an untracked new file is silently omitted and the published gem would raise LoadError. Confirmed via gem build that it's now packaged.

Verification

4 runs, 14 assertions, 0 failures, 0 errors, 0 skips

rake code_analysis0 total warnings. gem build succeeds with all four lib files packaged.

🤖 Generated with Claude Code

igray and others added 2 commits August 1, 2026 14:54
Bump the ruby-lsp dependency from `~> 0.17` to `~> 0.26` and raise
required_ruby_version to >= 3.0.0 to match what ruby-lsp now requires.

Addon changes:

- Implement `version`. Since 0.23 the addon base class treats it as
  abstract and uses it for the `Addon.get(name, constraint)` compatibility
  check, so without it any addon querying this one raises
  AbstractMethodInvokedError.

- Drop the sorbet-runtime dependency. ruby-lsp no longer depends on it and
  the only reference left here was a bare require; there is no `T.` or
  `T::Sig` usage anywhere in the gem.

Test changes: the suite hand-rolled `with_server` against internals that
have since been removed (`core_ext/uri`, `RubyIndexer::IndexablePath`). It
now uses the `RubyLsp::TestHelper` module that ruby-lsp ships for addons,
requires `ruby_lsp/internal` instead of a long explicit require list, and
uses `pop_result` so notifications in the queue don't break the assertions.
The expected reek docs URL is interpolated from `Reek::Version::STRING`
rather than hardcoded.

Clean up the reek warnings so `rake code_analysis` passes:

- `Runner#build_examiner` (FeatureEnvy) is gone. It existed to work around
  Examiner not accepting a separate source and origin, reaching into two of
  its instance variables to do so. `SourceCode.from(source, origin:)` takes
  an explicit origin and Examiner passes a SourceCode through untouched, so
  the workaround is no longer needed.

- `Runner#warning_to_diagnostic` (UtilityFunction) moves to
  `Reek::Diagnostic.from_warning`, which is what the smell was suggesting.

- `Runner#run_formatting` (UtilityFunction) is suppressed in place. The
  Formatter interface requires an instance method and reek is a linter, so
  there is nothing to format and no instance state to depend on.

The origin behaviour from #5 had no test, so add one covering it: a file
under a directory with a `.reek.yml` directory directive is exempt while a
file outside it is not. Verified it fails when the origin is dropped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`~> 6.0` already means `>= 6.0, < 7.0`, so the trailing `>= 5.0` was dead
and misleadingly suggested reek 5 was supported.

No change to which versions resolve. Verified the suite against reek 6.5.0,
the current latest.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@igray
igray marked this pull request as ready for review August 1, 2026 20:03
@igray
igray merged commit 9d05df3 into main Aug 1, 2026
2 checks passed
@igray igray mentioned this pull request Aug 1, 2026
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.

1 participant