Skip to content

feat: match baseline violations without asking the user how - #666

Open
fain182 wants to merge 1 commit into
mainfrom
baseline-drop-linenumbers-flag
Open

feat: match baseline violations without asking the user how#666
fain182 wants to merge 1 commit into
mainfrom
baseline-drop-linenumbers-flag

Conversation

@fain182

@fain182 fain182 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Choosing between matching the baseline with or without line numbers is a decision about how the baseline is compared, not about what to enforce — and both answers were wrong somewhere. The default reopened a known violation after any edit above it; --ignore-baseline-linenumbers could not tell two violations of the same rule in the same class apart, and could report the wrong one as new (#636).

Matching is now a single strategy with no knob, in two passes:

  1. violations still sitting where the baseline recorded them pair first;
  2. among what is left, class and reported problem alone decide.

So an edit above a violation moves it without making it new, identical violations in one class stay distinct, and when a violation is added among moved ones it is the added one that gets reported. The #636 scenario (three baselined violations at 10/20/30, a fourth added at 15) is covered by a test.

When a group of identical violations both moved and grew in the same run, which of them is reported as new is a guess — the count is not. That ambiguity is inherent, and it is documented in the README rather than papered over.

Deprecation: --ignore-baseline-linenumbers / ignoreBaselineLinenumbers() have no effect and print a notice, whether they come from the CLI or from phparkitect.php. They will be removed in the next major. generate-baseline always writes line numbers now; baselines stored without them keep working and need no regeneration, and prune-baseline still preserves that format.

Pairing stays linear: a synthetic 20k-entry baseline where every violation moved matches in 0.04s, and 2000 violations of the same rule in a single class in under 0.01s.

Built on #665, which put all matching in Violations::matchAgainst() — this PR is mostly the removal of the boolean from it.

Closes #662
Refs #636

Choosing between matching with or without line numbers was a decision
about how the baseline is compared, not about what to enforce, and both
answers were wrong somewhere: the default reopened known violations after
any edit above them, while --ignore-baseline-linenumbers could not tell
two violations of the same rule in the same class apart.

Matching is now a single strategy with no knob. Violations still sitting
where the baseline recorded them pair first; among what is left, class
and reported problem alone decide, so an edit above a violation moves it
without making it new, and identical violations in one class stay
distinct. When a violation is added among moved ones, it is the added one
that is reported.

--ignore-baseline-linenumbers and ignoreBaselineLinenumbers() are
deprecated: they have no effect and print a notice. generate-baseline
always writes line numbers; baselines stored without them keep working
and need no regeneration.

Closes #662
Refs #636

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.57%. Comparing base (17ddf48) to head (d9ce580).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #666      +/-   ##
============================================
- Coverage     97.79%   97.57%   -0.22%     
- Complexity      760      762       +2     
============================================
  Files           101      101              
  Lines          2180     2190      +10     
============================================
+ Hits           2132     2137       +5     
- Misses           48       53       +5     
Files with missing lines Coverage Δ
src/CLI/Baseline.php 91.30% <100.00%> (-8.70%) ⬇️
src/CLI/CheckHandler.php 100.00% <100.00%> (ø)
src/CLI/Command/CommonOptions.php 100.00% <100.00%> (ø)
src/CLI/Config.php 75.00% <ø> (-4.69%) ⬇️
src/CLI/GenerateBaselineHandler.php 100.00% <100.00%> (ø)
src/CLI/Runner.php 100.00% <100.00%> (ø)
src/Rules/Violations.php 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fain182
fain182 requested a review from micheleorselli July 26, 2026 21:24

@AlessandroMinoccheri AlessandroMinoccheri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

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 matching should not require the user to pick a strategy (line numbers vs. not)

2 participants