Skip to content

fix(server): smaller issues found on real Rails apps - #249

Merged
x-ror merged 5 commits into
mainfrom
fix/corpus-small-items
Nov 14, 2026
Merged

x-ror merged 5 commits into
mainfrom
fix/corpus-small-items

Conversation

@x-ror

@x-ror x-ror commented Nov 14, 2026

Copy link
Copy Markdown
Owner

The rest of the run over real Rails apps: smaller items before 1.0.

Changes

  • ERB formatting no longer leaves a whole file unchanged because of one inline <%= tag.style x %>, tag.script(src: x) or javascript_tag "x". A helper that opens a block (do, {) still makes the formatter skip the file, since its body is raw text.
  • insert_final_newline = true in .editorconfig turns Layout/TrailingEmptyLines on for ERB. .ruby-templates.toml still wins.
  • Rails/UnsafeOutput:
    • Now quiet:
      • a string whose interpolations are all HTML-safe: "Hi #{h(name)}".html_safe, including adjacent literals;
      • truncate(...), which Rails escapes unless escape: is false.
    • Still reported:
      • j and escape_javascript inside an HTML string, since they leave < alone;
      • truncate with escape: false, a computed escape:, options passed as a variable, or splatted arguments.
    • Message: long or multi-line code is quoted, cut at 40 characters with …, instead of saying "its value".
  • Missing Gemfile.lock: check prints one note on stderr per Rails-looking app that has no Gemfile.lock, because its Rails/*, Stimulus/* and Turbo/* rules are off. Stdout and exit codes are unchanged, so machine formats stay clean.
  • Jbuilder and Builder: --help and the command-line guide no longer claim Ruby syntax errors for these views. Neither check nor the editor reports them; they are left to Ruby LSP.

Left out:

  • Kaminari's generated views (raw t('views.pagination.first')): this is a translation without an _html key, so Rails doesn't mark it safe and the rule is right. Exclude those views with [Rails/UnsafeOutput] exclude = ["app/views/kaminari/**"].
  • Cosmetic formatter items: the whitespace before </script> belongs to the script (and to <textarea>), and the content of a <p> closed implicitly by the next one follows the HTML tree.

Tests

  • Rust unit tests:
    • inline script and style helpers;
    • insert_final_newline reading and precedence;
    • safe interpolations, JS escapers, adjacent literals, truncate options and splats;
    • message cutting.
    • 1005 tests pass.
  • test/cli.js: the lockfile note once per app, with absolute and relative paths and from inside app/views; clean --format json stdout; Jbuilder output.
  • Other checks: test:server, e2e, test:rules, test:format and format:check pass.

Generated by Claude Code

One `<%= tag.style x %>` made the formatter leave a whole forem view
unchanged: any script or style helper call was taken for a raw-text
block. Only a helper that opens a block holds raw text, so only that
still makes the formatter skip the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jSfzj1UNFUHV9YmmbjLg4
Layout/TrailingEmptyLines is off by default for ERB, so an
.editorconfig asking for a final newline had no effect there. The
setting now turns the rule on unless .ruby-templates.toml turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jSfzj1UNFUHV9YmmbjLg4
Real apps marked `"#{h(x)}".html_safe` and `truncate(...)` safe and got
reports: an interpolation of only escaped values is safe, and Rails'
truncate escapes unless escape: false. The message also quotes long or
multi-line code, cut, instead of saying "its value".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jSfzj1UNFUHV9YmmbjLg4
…uilder

Without Gemfile.lock the Rails, Stimulus and Turbo rules turn off
silently, which a CI job with a partial checkout never notices; check
now says so once per app on stderr, leaving stdout and exit codes as
they were. The help claimed Ruby syntax errors in Jbuilder and Builder
views, which neither check nor the editor reports (they are left to
Ruby LSP), so it now says what is checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jSfzj1UNFUHV9YmmbjLg4
… the note

Review found that trusting safe interpolations also trusted `j` and
`escape_javascript`, which leave `<` alone, so `"<p>#{j(@q)}</p>".html_safe`
went quiet where main reported it. Splatted truncate arguments may hold
escape: false and are reported again; adjacent literals with safe
interpolations are quiet like a single literal. The missing-lockfile
note found the app from the path as typed, so relative paths gave an
empty or no app name; it now uses the absolute path the checks use.
insert_final_newline moves from the formatter's settings to the
resolved config it is read from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jSfzj1UNFUHV9YmmbjLg4
@x-ror
x-ror merged commit 1697c3c into main Nov 14, 2026
16 of 17 checks passed
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.

2 participants