You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[duplicate-code] Duplicate Code: tool-call diff entries duplicated in general and bash audit summaries #71232
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.
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
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.
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.
Activity