fix: symmetric move detection in PR-review rules#78
Open
smochan wants to merge 1 commit into
Open
Conversation
…ction) A relocated function appears in the graph diff as one node removed and another added with the same terminal name. The removed-side removed-referenced rule already recognized this; the added-side "new code" rules did not, so a move flagged formatQn as a new-untested-hotspot and moved orphans as new-dead-code. Extract the move check into a shared _is_moved helper plus precomputed added_names/removed_names sets, and apply it symmetrically: new_dead_code and new_untested_hotspot now skip symbols whose terminal name exists in the removed set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
codegraph PR reviewDiff vs main · severity ≤
|
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.
Problem
A relocated function shows up in the graph diff as one node removed and another added sharing the same terminal name. A prior fix (PR #73, esc/pyvisHref) taught the removed-side
removed-referencedrule to recognize a move and not flag it as a critical deletion — but the fix was one-sided. The added-side "new code" rules still misfired on the same relocation:formatQnwas reported as anew-untested-hotspotafter movingapp.js→ui/helpers.jsnew-dead-codeA relocated symbol is not new code; its coverage and reachability state predate the PR that moved it.
Fix
Make move detection symmetric:
_is_moved(change, counterpart)helper plus precomputedadded_names/removed_namessets inevaluate_rules.removed_referencednow uses the helper (behavior unchanged).new_dead_codeandnew_untested_hotspotnow skip symbols whose terminal name + kind appears in the removed set.Every built-in rule that treats a node as newly-added or removed code now accounts for moves. The generic
added_node/removed_nodewhens have no built-in rule, so there is no remaining gap.Tests
test_new_untested_hotspot_skips_moved_symbol(regression)test_new_untested_hotspot_still_fires_for_genuinely_new(control — genuinely new high-fan-in untested fn still fires)test_new_dead_code_skips_moved_symbol(regression)pytest tests/ -k review→ 40 passed.🤖 Generated with Claude Code