feat: add autofix for legacy_comment and near_duplicate findings#940
Merged
feat: add autofix for legacy_comment and near_duplicate findings#940
Conversation
Add two new fixers to the refactor pipeline: - comment_fixes: removes stale LegacyComment and TodoMarker lines via DocLineRemoval. Parses line number from the finding description. - near_duplicate_fixes: consolidates structurally identical functions across files. Picks the canonical copy (first alphabetically), removes the duplicate via FunctionRemoval, adds a use import, and upgrades visibility to pub(crate) on the canonical if needed. All Safe tier — sandbox validation + cargo check catches breakage before merge. Both fixers are registered in generate_fixes_impl() and fixability auto-derives from compute_fixability().
Contributor
Homeboy Results —
|
…ments The legacy comment fixer was wrong — it deleted the comment line and left the actual legacy code behind. The comment is a SIGNAL that legacy fallback code exists. The fix is removing the entire code block. New behavior: - Reads the source file and classifies what the comment annotates - Function definition → Safe FunctionRemoval of comment + entire fn - Guard clause (if without else) → Safe removal of comment + if block - Match arm → Safe removal of comment + arm - Else branch → PlanOnly (control flow change needs review) - Code section → PlanOnly (heuristic boundaries need review) - Unknown → PlanOnly (manual review required) - TodoMarker → always PlanOnly (describes work, not code to remove) Block detection uses brace-depth tracking, indent analysis, and backward scanning for else branches.
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.
Summary
LegacyCommentandTodoMarkerfindings viaDocLineRemoval. Parses line number from the audit description. Safe tier.useimport, upgrades visibility topub(crate)on canonical if needed. Safe tier — sandbox validation gates correctness.Both registered in
generate_fixes_impl(). Fixability auto-derives.Finding coverage after this PR
legacy_commenttodo_markernear_duplicateCloses #929 (legacy_comment)
Addresses #542 (near_duplicate — 16 findings now fixable)