Skip to content

[duplicate-code] Duplicate Code: tool-call diff entries duplicated in general and bash audit summaries #71232

Open

Description

@github-actions

🔍 Duplicate Code Detected: tool-call diff classification

Analysis of commit a02442b3481abf48dc4757e9a18a1c83f35b2e66 (latest reviewed: fb1cd0f618da8729f7daae5273dfb83d36ee5de4)

Assignee requested: @copilot (the available issue-creation interface does not expose an assignee field).

Summary

The newly extracted general tool-call diff helper and the existing bash-command diff independently classify new, removed, and changed calls and populate the same ToolCallDiffEntry fields. Approximately 20 lines of structurally similar diff logic occur in both.

<b>Duplication details</b>
entry := ToolCallDiffEntry{
    Name: name,
    Run1CallCount: tc1.CallCount, Run2CallCount: tc2.CallCount,
    Run1MaxInputSize: tc1.MaxInputSize, Run2MaxInputSize: tc2.MaxInputSize,
    Run1MaxOutputSize: tc1.MaxOutputSize, Run2MaxOutputSize: tc2.MaxOutputSize,
}

The general path uses map membership for new/removed status; the bash path uses positive call counts. The bash path formats CallCountChange even for new/removed entries. Preserve these intentional differences. Serena references confirm both are reached from computeToolCallsDiff.

Impact analysis

  • Maintainability: Field additions or formatting changes require two updates to the same output model.
  • Bug risk: General and bash summaries can diverge, particularly for zero-count entries and new/removed count deltas.
  • Code bloat: Roughly 20 similar lines in the two entry-building branches.

Refactoring recommendations

  1. Extract a private pure entry-construction helper in pkg/cli/audit_diff.go; leave summary aggregation and counts with their callers. Keep membership-versus-positive-count and delta behavior explicit. Effort: about 2–3 hours.
  2. Add coverage for new, removed, changed, unchanged and zero-count entries, checking existing bash delta formatting.

Implementation checklist

  • Confirm the intentional classification differences
  • Extract shared entry construction without changing behavior
  • Keep summary aggregation separate
  • Update targeted tests and verify unchanged output
<b>Analysis metadata</b>
  • Analyzed files: 5 production Go files changed among the latest 15 commits; test files, workflow files, and non-Go files excluded.
  • Detection method: Serena symbol bodies, references and pattern search, plus recent commit diffs.
  • Introduced by extraction in: a02442b3481abf48dc4757e9a18a1c83f35b2e66.
  • Analysis date: 2026-10-22 UTC.

References: §39860337663

Generated by 🔍 Duplicate Code Detector · pi · routed: gpt60 xhigh · ~59 AIC · ⌖ ~1 AIC · ⊞ 347 · ◷

  • expires on Oct 24, 2026, 1:58 PM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions