Skip to content

Make solargraph config self-documenting - #70

Closed
apiology wants to merge 4 commits into
masterfrom
worktree-typecheck-rule-opt-in
Closed

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

Conversation

@apiology

Copy link
Copy Markdown
Owner

Problem:

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 (098b0670b) — handy for moving a large codebase to a stricter level one rule at a time — but nothing in the generated file says so.

Solution:

solargraph config now documents every option inline, type_checker.rules included.

Also:

  • solargraph config crashed the moment any solargraph-*-ext gem was installed (conf['extensions'] referenced a key the defaults never defined).
  • Two unrelated latent bugs found in passing: Rules#level always returned nil; Workspace#rules ignored its level argument after the first call.

apiology and others added 3 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.
@apiology
apiology marked this pull request as ready for review September 7, 2026 01:03
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 commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

Claude:

Superseded by castwide#1350, which carries the same branch and head ec64b2e upstream. Closing this so the branch has one PR.

@apiology apiology closed this Sep 8, 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