Skip to content

Conversation

@adam12
Copy link
Contributor

@adam12 adam12 commented Dec 9, 2025

Motivation

Closes #3845

RubyLSP will helpfully log the formatter and linter detected, but not indicate
how or why it came to that conclusion. This can make it difficult to ascertain
whether the detection was correct.

Implementation

The detection methods for formatters, linters, test libraries, and type checkers
were updated to return not just the detected tool, but also a string indicating
the reason for the detection. The logging statements were updated to include
this reason.

A regular class for the detection result (vs Data) was chosen for Ruby compatibility.

Automated Tests

No tests were addeed specifically for this logging change.

Manual Tests

When running the LSP, you can observe the log messages to see the detection reasons.

Log messages for auto-detected formatters, linters, test libraries,
and type checkers now include the reason why they were detected.

For example:
- "Auto detected formatter: rubocop_internal (direct dependency matching /^rubocop/)"
- "Detected test library: rails (bin/rails present)"

This helps users debug false positives by understanding which
detection heuristics triggered.

Fixes Shopify#3845
@adam12 adam12 requested a review from a team as a code owner December 9, 2025 15:58
@vinistock vinistock added server This pull request should be included in the server gem's release notes other Changes that aren't bugfixes, enhancements or breaking changes labels Dec 15, 2025
#: (Array[String] dependencies) -> [bool, String]
def detect_typechecker(dependencies)
return false if ENV["RUBY_LSP_BYPASS_TYPECHECKER"]
if ENV["RUBY_LSP_BYPASS_TYPECHECKER"]
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with the other methods, can we also return a DetectionResult here?

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

Labels

other Changes that aren't bugfixes, enhancements or breaking changes server This pull request should be included in the server gem's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log entries for auto-detected libraries could indicate how they were detected

2 participants