Skip to content

Count each duplicate under its own extension in Stats [patch] - #168

Merged
matt-edmondson merged 4 commits into
mainfrom
fix/stats-extension-breakdown
Oct 6, 2026
Merged

matt-edmondson merged 4 commits into
mainfrom
fix/stats-extension-breakdown

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #146

What changed

The "Duplicate files by extension" breakdown in Stats credited each whole group to the extension of group.Files[0]. That caused three problems:

  • Mixed-extension duplicates were all counted under a single extension.
  • The extension changed from run to run, because Files[0] is whichever copy the parallel hash happened to list first.
  • The keeper was counted too, so the breakdown summed to more than "Duplicate files".

Now each copy other than Deduplicator.SelectFileToKeep's keeper is counted under its own extension. Rows with equal counts are ordered by extension, so the output is the same on every run.

Tests

  • New test, VerbOutputTests.StatsBreaksDuplicatesDownByEachCopysOwnExtension. It runs Stats three times on photo.jpg, photo-copy.png and backup.bak, all with identical content. Every run reports Duplicate files: 2, a breakdown of .bak: 1 and .png: 1, and no .jpg row, since photo.jpg is the keeper. With the Stats.cs change reverted, this test fails.
  • Changed test, StatsReportsTotalsForTheTree. It asserted .txt: 3 file(s) alongside Duplicate files: 2, which is exactly the inconsistency the issue describes. It now expects .txt: 2 file(s).

The full suite passes: 60 passed, 2 pre-existing skips.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q5ZFyLG9PgeKn5RpzhWEUQ


Generated by Claude Code

claude added 2 commits October 6, 2026 09:28
The extension breakdown credited a whole group to the extension of
Files[0], which included the copy that is kept and was whichever copy
the parallel hash listed first. Mixed-extension duplicates landed under
one extension that changed between runs, and the totals exceeded
"Duplicate files".

Each redundant copy is now counted under its own extension, the keeper
is left out, and ties are ordered by extension so the output is stable.

Fixes #146

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZFyLG9PgeKn5RpzhWEUQ
Brings Stats.Run back under SonarCloud's cognitive complexity limit
(S3776).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZFyLG9PgeKn5RpzhWEUQ
Comment thread FileDeduplicator/Verbs/Stats.cs Fixed
claude added 2 commits October 6, 2026 09:37
Addresses the code-quality review on this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZFyLG9PgeKn5RpzhWEUQ
# Conflicts:
#	FileDeduplicator.Test/VerbOutputTests.cs
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 9275c65 into main Oct 6, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/stats-extension-breakdown branch October 6, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants