Skip to content

feat: expand intra-method duplicate fixer to handle non-adjacent blocks#941

Merged
chubes4 merged 1 commit intomainfrom
feat/intra-dup-cross-branch
Mar 23, 2026
Merged

feat: expand intra-method duplicate fixer to handle non-adjacent blocks#941
chubes4 merged 1 commit intomainfrom
feat/intra-dup-cross-branch

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 23, 2026

Summary

  • Rewrote the intra-method duplicate fixer with a structural classifier
  • Language-agnostic: operates on line content, indentation levels, and gap analysis — no language parsing
  • Uses median indentation to detect cross-branch duplication vs same-level repetition

Classification

Relation Detection Safety Action
Adjacent Gap is blank/comment only Safe Remove second block
Same-indent small gap ≤3 code lines between, same indent Safe Remove second block
Same-indent large gap >3 code lines between, same indent PlanOnly Flag for review
Cross-branch Different median indentation PlanOnly Flag with refactoring hint

Impact

Before: 1/82 findings fixable (1.2%)
After: All 82 findings generate a fix — adjacent/same-indent as Safe, cross-branch as PlanOnly

Addresses #538

The fixer only handled adjacent duplicates (1/82 fixable). Rewrote with
a structural classifier that's language-agnostic — operates on line
content, indentation, and gap analysis. No language parsing.

Classification:
- Adjacent (gap is blank/comment only) → Safe, remove second block
- Same-indent small gap (≤3 code lines between) → Safe, remove second
- Same-indent large gap (>3 code lines) → PlanOnly, flag for review
- Cross-branch (different indent levels) → PlanOnly with refactoring hint

Uses median indentation to detect cross-branch duplication (if/else,
match arms) vs same-level repetition (merge artifacts, copy-paste).
@chubes4 chubes4 merged commit 694fde6 into main Mar 23, 2026
1 check passed
@homeboy-ci
Copy link
Contributor

homeboy-ci bot commented Mar 23, 2026

Homeboy Results — homeboy

Audit

Failure Digest

Audit Failure Digest

  • Alignment score: 0.921
  • Severity counts: unknown: 3, warning: 7
  • Outliers in current run: 3
  • Parsed outlier entries: 3
  • Drift increased: yes
  • New findings since baseline: 7
    1. intra-method-duplication — Duplicated block in generate_intra_duplicate_fixes — 5 identical lines at line 134 and line 172 (intra-method-duplication::src/core/refactor/plan/generate/intra_duplicate_fixes.rs::IntraMethodDuplicate)
    2. test_coverage — Method 'generate_intra_duplicate_fixes' has no corresponding test (expected 'test_generate_intra_duplicate_fixes') (test_coverage::src/core/refactor/plan/generate/intra_duplicate_fixes.rs::MissingTestMethod)
    3. test_coverage — Test method 'test_classify_adjacent_blank_gap' references 'classify_adjacent_blank_gap' which no longer exists in the source (test_coverage::src/core/refactor/plan/generate/intra_duplicate_fixes.rs::OrphanedTest)
    4. test_coverage — Test method 'test_classify_adjacent_no_gap' references 'classify_adjacent_no_gap' which no longer exists in the source (test_coverage::src/core/refactor/plan/generate/intra_duplicate_fixes.rs::OrphanedTest)
    5. test_coverage — Test method 'test_classify_cross_branch_different_indent' references 'classify_cross_branch_different_indent' which no longer exists in the source (test_coverage::src/core/refactor/plan/generate/intra_duplicate_fixes.rs::OrphanedTest)
  • Top actionable findings:
    1. src/core/refactor/plan/generate/intra_duplicate_fixes.rs — intra_method_duplicate — Duplicated block in generate_intra_duplicate_fixes — 5 identical lines at line 134 and line 172
    2. src/core/refactor/plan/generate/intra_duplicate_fixes.rs — missing_test_method — Method 'generate_intra_duplicate_fixes' has no corresponding test (expected 'test_generate_intra_duplicate_fixes')
    3. src/core/refactor/plan/generate/intra_duplicate_fixes.rs — orphaned_test — Test method 'test_classify_adjacent_blank_gap' references 'classify_adjacent_blank_gap' which no longer exists in the source
    4. src/core/refactor/plan/generate/intra_duplicate_fixes.rs — orphaned_test — Test method 'test_classify_adjacent_no_gap' references 'classify_adjacent_no_gap' which no longer exists in the source
    5. src/core/refactor/plan/generate/intra_duplicate_fixes.rs — orphaned_test — Test method 'test_classify_cross_branch_different_indent' references 'classify_cross_branch_different_indent' which no longer exists in the source
All parsed audit findings (10)
1. **src/core/refactor/plan/generate/intra_duplicate_fixes.rs** — intra_method_duplicate — Duplicated block in `generate_intra_duplicate_fixes` — 5 identical lines at line 134 and line 172
2. **src/core/refactor/plan/generate/intra_duplicate_fixes.rs** — missing_test_method — Method 'generate_intra_duplicate_fixes' has no corresponding test (expected 'test_generate_intra_duplicate_fixes')
3. **src/core/refactor/plan/generate/intra_duplicate_fixes.rs** — orphaned_test — Test method 'test_classify_adjacent_blank_gap' references 'classify_adjacent_blank_gap' which no longer exists in the source
4. **src/core/refactor/plan/generate/intra_duplicate_fixes.rs** — orphaned_test — Test method 'test_classify_adjacent_no_gap' references 'classify_adjacent_no_gap' which no longer exists in the source
5. **src/core/refactor/plan/generate/intra_duplicate_fixes.rs** — orphaned_test — Test method 'test_classify_cross_branch_different_indent' references 'classify_cross_branch_different_indent' which no longer exists in the source
6. **src/core/refactor/plan/generate/intra_duplicate_fixes.rs** — orphaned_test — Test method 'test_classify_same_indent_large_gap' references 'classify_same_indent_large_gap' which no longer exists in the source
7. **src/core/refactor/plan/generate/intra_duplicate_fixes.rs** — orphaned_test — Test method 'test_classify_same_indent_small_gap' references 'classify_same_indent_small_gap' which no longer exists in the source
8. **src/commands/docs.rs** — outlier — (outlier)
9. **tests/commands/deploy_test.rs** — outlier — (outlier)
10. **src/core/engine/undo/rollback.rs** — outlier — (outlier)
- Full audit log: https://github.com/Extra-Chill/homeboy/actions/runs/23419934041

Autofixability classification

  • Overall: auto_fixable
  • Autofix enabled: yes
  • Autofix attempted this run: no
  • Auto-fixable failed commands:
    • audit
  • Failed commands with available automated fixes:
    • audit

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

audit (changed files only)

Auto-refactor

ℹ️ Autofix enabled, but no fixable file changes were produced

Failure Digest

Autofixability classification

  • Overall: human_needed
  • Autofix enabled: yes
  • Autofix attempted this run: no
  • Human-needed failed commands:
    • refactor --from all

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

refactor --from all

Tooling versions
  • Homeboy CLI: homeboy 0.85.3+7e48300
  • Extension: rust from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v2

Homeboy Action v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant