Skip to content

Code duplication detection as a vibe-check structural gate #13

Description

@jflowers

Summary

Add code duplication detection as a structural quality gate in vibe-check, integrated into the vibe-check analyze command with a configurable duplication threshold.

RFC: https://github.com/orgs/unbound-force/discussions/483 — Group 8
Phase: P2 (Accessibility)

Context

Duplicated code is a significant maintainability risk, especially with agent-written code where agents may not be aware of existing implementations. Detection gives agents and reviewers visibility into redundancy.

Implementation

vibe-check Integration

  • Add duplication detection to vibe-check analyze
  • Use AST-based structural similarity for Go (leveraging go/ast)
  • Configurable threshold: max percentage of duplicated code
  • Report duplicated blocks with file locations and similarity scores

CI Gate

vibe-check analyze ./... --max-duplication=5

Exit code non-zero if duplication exceeds the threshold.

Output

  • Duplication percentage per package
  • List of duplicated code blocks with locations
  • Included in the metrics.ModuleGraph output (via warnings or a dedicated field)

Acceptance Criteria

  • Duplication detection integrated into vibe-check analyze
  • AST-based structural similarity for Go
  • --max-duplication flag with configurable threshold (default: 5%)
  • CI fails when duplication exceeds threshold
  • Duplication report included in JSON output
  • Supports AD-008 (DRY) from the convention pack
  • Tests with sample codebases containing known duplicates

Dependencies

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority — Phase 3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions