Repository navigation
Conversation
The Prism ERB scanner parsed the body of `<%# ... %>` comments as Ruby,
only turning `i18n-tasks-use` into a comment. Any commented-out code such
as `<%# User.human_attribute_name(:foo) %>` or `<%# t("key") %>` was thus
reported as a used key. Turn every line of an ERB comment into a Ruby
comment so that only the `i18n-tasks-use` magic comments are picked up,
matching the Parser-based scanner.
Fixes glebm#746
davidwessman
reviewed
Oct 9, 2026
davidwessman
left a comment
Collaborator
There was a problem hiding this comment.
It looks good, please fix the conflicts and the rubocop errors. I will try to fix the Simplecov warnings on main.
Collaborator
|
@copilot resolve the merge conflicts on this branch. |
Collaborator
|
Merged in #763 |
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.
Description
The Prism-based ERB scanner (
ErbAstScanner#process_comments) parsed the body of an ERB comment (<%# ... %>) as Ruby code, only rewritingi18n-tasks-useinto#i18n-tasks-use. As a result, any commented-out code inside an ERB comment was treated as live code, e.g.was reported as using
activerecord.attributes.model_class.unknown/some.key(and therefore as missing keys). The Parser-based scanner already treats ERB comments as comments and only reads magic comments from them.This change turns every line of an ERB comment into a Ruby comment (stripping leading whitespace/
#), so Prism only sees comments and the existing magic-comment handling picks upi18n-tasks-uselines (single-line, multi-line and<%#-forms keep working), while commented-out code is ignored.The
comments.html.erbfixture gets a few commented-out calls (t(...),human_attribute_name, multi-line); the Prism spec asserts they are not reported. The same fixture is used by the Parser ERB spec, which already passes with it.Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to
help projects with open good-first-issues. The change was prepared with Claude Code and verified as listed
below. If it doesn't fit, isn't up to your bar, or you'd simply rather not take it — please feel free to
close it, no hard feelings at all 🙂
Related issue
Closes #746
Checklist
bundle exec rakewithRUBYOPT="--enable-frozen-string-literal --debug-frozen-string-literal"on Ruby 3.4.9: 286 examples, 0 failures, 5 pending — Google Translate specs, no API key). New assertions fail without the fix (11 used keys instead of 8).bundle exec rubocop: no new offenses (the 5Lint/InterpolationCheckoffenses inspec/used_keys_erb_spec.rbalso exist onmain).CHANGES.mdis updated (if applicable) — entry under "Unreleased"