Repository navigation
Don't flag a local variable named fixture_path - #26
Merged
Merged
Conversation
Ruby reads a bare `fixture_path = x` as a local variable assignment, never as a call to the removed setter, so the rule now needs a receiver (`self.`, `config.`, `ActiveSupport::TestCase.`). It also stops matching an instance variable (`@fixture_path = x`) and a comparison (`==`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks, this is right. A bare One small optional change:
Neither is likely in real code, though. |
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.
Ran 0.1.2 against a private app going from Rails 7.1 to 7.2.
fixture_path_assignmentmatched 7 lines in its spec helpers, all a local variable:Ruby reads a bare
name = xas a local variable, never a call to the setter, so the removedfixture_path=always has a receiver. The pattern goes from\bfixture_path\s*=to\.fixture_path\s*=(?!=):self.fixture_path = xconfig.fixture_path = "spec/fixtures"ActiveSupport::TestCase.fixture_path = xfixture_path = build(route)@fixture_path = xself.fixture_path == xconfig.fixture_paths = [x]Two lines go into
NEAR_MISSES(the local and the instance variable). With the old pattern,test_replacement_apis_are_not_flaggedfails on both; with the new one the suite passes (97 runs, 0 failures). On the app, the 7 hits go to 0 and nothing else in the report changes (blockers 3 → 2).🤖 Generated with Claude Code