Repository navigation
fix(server): smaller issues found on real Rails apps - #249
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rest of the run over real Rails apps: smaller items before 1.0.
Changes
<%= tag.style x %>,tag.script(src: x)orjavascript_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 = truein.editorconfigturnsLayout/TrailingEmptyLineson for ERB..ruby-templates.tomlstill wins.Rails/UnsafeOutput:"Hi #{h(name)}".html_safe, including adjacent literals;truncate(...), which Rails escapes unlessescape:is false.jandescape_javascriptinside an HTML string, since they leave<alone;truncatewithescape: false, a computedescape:, options passed as a variable, or splatted arguments.…, instead of saying "its value".Gemfile.lock:checkprints one note on stderr per Rails-looking app that has noGemfile.lock, because itsRails/*,Stimulus/*andTurbo/*rules are off. Stdout and exit codes are unchanged, so machine formats stay clean.--helpand the command-line guide no longer claim Ruby syntax errors for these views. Neitherchecknor the editor reports them; they are left to Ruby LSP.Left out:
raw t('views.pagination.first')): this is a translation without an_htmlkey, so Rails doesn't mark it safe and the rule is right. Exclude those views with[Rails/UnsafeOutput] exclude = ["app/views/kaminari/**"].</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
insert_final_newlinereading and precedence;truncateoptions and splats;test/cli.js: the lockfile note once per app, with absolute and relative paths and from insideapp/views; clean--format jsonstdout; Jbuilder output.test:server,e2e,test:rules,test:formatandformat:checkpass.Generated by Claude Code