Skip to content

Document every option in the generated .solargraph.yml - #1350

Open
apiology wants to merge 4 commits into
castwide:masterfrom
apiology:worktree-typecheck-rule-opt-in
Open

Document every option in the generated .solargraph.yml#1350
apiology wants to merge 4 commits into
castwide:masterfrom
apiology:worktree-typecheck-rule-opt-in

Conversation

@apiology

@apiology apiology commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

This PR was written by Claude Code on behalf of @apiology.

Problem: solargraph config writes a file that says nothing about what any setting does or what values it accepts.

---
include:
- Rakefile
- Gemfile
- "*.gemspec"
- "./**/*.rb"
exclude:
- spec/**/*
require: []
domains: []

type_checker.rules is the sharpest case: it takes a level name per rule, and nothing in the generated file or an error message says so, while a misspelled level took down the whole typecheck run with comparison of Integer with nil failed.

Solution: Emit a documented comment above each key, and drop rule overrides naming a level that does not exist so a typo warns and falls back instead of raising.

apiology and others added 4 commits August 27, 2026 15:35
solargraph config generates a .solargraph.yml, but the file explains
nothing about what any option does or accepts - you have to read
source or find solargraph.org to make sense of it. type_checker.rules
is a good example: it lets you override an individual typecheck rule
level (098b067), but nothing in the generated file said so.

Adds a CONFIG_DOCS table and Config.commented_yaml, so solargraph
config now writes a doc comment above every top-level key, including
type_checker.rules.

Also fixes a crash in that same command: conf['extensions'] was
pushed to when a solargraph-*-ext gem was installed, but the key
never existed in the defaults. And two unrelated latent bugs found
in passing: Rules#level always returned nil (a wrong hash lookup;
nothing in production code reads it, which is why it went
unnoticed), and Workspace#rules ignored its level argument after the
first call (memoized on the first level requested, regardless of
what was asked for later).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UtuMwbDhKyt9bAPC19T5xF
Compress two comments PR 70 added in
lib/solargraph/workspace/config.rb to fit the repo's comment-length
budget.

The CONFIG_DOCS constant docstring dropped from 4 prose lines to 2,
keeping only what a reader can't get from the code: what generates
the comment, and that a missing key renders with none.

The @sg-ignore above the Psych.dump call in commented_yaml was five
lines; the convention here (see lib/solargraph/type_checker/rules.rb)
is a single-line reason. Full diagnostic for anyone re-verifying this
suppression: Psych.dump's RBS signature declares optional kwargs
(indentation:, line_width:, ...) in addition to its positional args,
so `YAML.dump({ key => value })` - a single positional Hash built
with `=>` - gets misread by the type checker as an attempt to pass
those kwargs, producing "Unrecognized keyword argument key to
Psych.dump". Worth filing upstream against castwide/solargraph as a
Psych.dump RBS/kwarg-vs-positional-Hash false positive; not filed as
part of this pass.
A typo in the type_checker rules block of .solargraph.yml took down the
whole typecheck run with "comparison of Integer with nil failed".
Config#type_checker_rules converts each value with a bare to_sym and
never checks it against LEVELS, so report? looked the value up, got nil,
and compared an Integer against it.

Drop unrecognized overrides at construction and warn, mirroring what
the constructor already does for an unrecognized primary level. The
rule then falls back to its own default level rather than crashing.
@apiology
apiology marked this pull request as ready for review September 8, 2026 21:15
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