Skip to content

Fix baseline duplicate replacements - #6872

Open
LizunovSergey wants to merge 2 commits into
realm:mainfrom
LizunovSergey:fix/baseline-duplicate-swap
Open

Fix baseline duplicate replacements#6872
LizunovSergey wants to merge 2 commits into
realm:mainfrom
LizunovSergey:fix/baseline-duplicate-swap

Conversation

@LizunovSergey

Copy link
Copy Markdown

Fixes #6871

Summary

  • report a same-count replacement of identical baseline violations when another duplicate still matches exactly
  • preserve the existing behavior for uniformly shifted duplicate violations

Root cause

After exact matches are removed, the fallback comparison used only the number of remaining violations with the same text and reason. A replacement could therefore be hidden by an unmatched baseline duplicate with the same key.

An unchanged duplicate now acts as an anchor: if the remaining counts are equal within that group, the unmatched current violations are reported. A group with no exact match still follows the existing shift-tolerant behavior.

Tests

  • swift test --filter BaselineTests

@LizunovSergey
LizunovSergey marked this pull request as ready for review August 15, 2026 18:06
@SwiftLintBot

SwiftLintBot commented Aug 15, 2026

Copy link
Copy Markdown
20 Messages
📖 Building this branch resulted in a binary size of 28461.48 KiB vs 28460.51 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.64 s vs 0.62 s on main (3% slower).
📖 Linting Alamofire with this PR took 0.92 s vs 0.92 s on main (0% slower).
📖 Linting Brave with this PR took 5.88 s vs 5.89 s on main (0% faster).
📖 Linting Brigade with this PR took 15.86 s vs 15.85 s on main (0% slower).
📖 Linting DuckDuckGo with this PR took 27.06 s vs 27.13 s on main (0% faster).
📖 Linting Firefox with this PR took 10.47 s vs 10.46 s on main (0% slower).
📖 Linting Kickstarter with this PR took 6.76 s vs 6.74 s on main (0% slower).
📖 Linting Moya with this PR took 0.38 s vs 0.37 s on main (2% slower).
📖 Linting NetNewsWire with this PR took 2.32 s vs 2.35 s on main (1% faster).
📖 Linting Nimble with this PR took 0.56 s vs 0.57 s on main (1% faster).
📖 Linting PocketCasts with this PR took 6.85 s vs 6.87 s on main (0% faster).
📖 Linting Quick with this PR took 0.34 s vs 0.32 s on main (6% slower).
📖 Linting Realm with this PR took 2.84 s vs 2.89 s on main (1% faster).
📖 Linting Sourcery with this PR took 1.61 s vs 1.58 s on main (1% slower).
📖 Linting Swift with this PR took 4.15 s vs 4.17 s on main (0% faster).
📖 Linting SwiftLintPerformanceTests with this PR took 0.16 s vs 0.16 s on main (0% slower).
📖 Linting VLC with this PR took 1.24 s vs 1.24 s on main (0% slower).
📖 Linting Wire with this PR took 15.16 s vs 15.17 s on main (0% faster).
📖 Linting WordPress with this PR took 9.51 s vs 9.53 s on main (0% faster).

Generated by 🚫 Danger

@yunusdim

Copy link
Copy Markdown

Author of #6871. The anchor approach is the right call: an unchanged duplicate is the evidence that the group did not shift, which is exactly the distinction the old fallback could not make. Keeping the shift-tolerant path where no exact match survives leaves the intentional behaviour intact.

One residual worth stating, not a request to change anything. When every duplicate in a group is replaced in the same run, no anchor survives, the group falls through to the shift-tolerant path, and the swap stays invisible. That is narrower than what #6871 reported — it needs the whole group to turn over at once — but it is the same shape, and it is better known now than discovered later.

Reason and line text remain the only keys on that path, so the residual is bounded by how generic those are. todo, mark and orphaned_doc_comment are where it would show.

Checks are green apart from the ones waiting on maintainer approval.

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.

Baseline: a same-count swap of duplicate-text violations within a rule is invisible

4 participants