Skip to content

ignored line numbers in the baseline#621

Open
AlessandroMinoccheri wants to merge 1 commit into
mainfrom
feature/ignore-line-numbers
Open

ignored line numbers in the baseline#621
AlessandroMinoccheri wants to merge 1 commit into
mainfrom
feature/ignore-line-numbers

Conversation

@AlessandroMinoccheri

Copy link
Copy Markdown
Member

Fix --ignore-baseline-linenumbers not applied when generating baseline
Fixes #620

When using --generate-baseline --ignore-baseline-linenumbers, line numbers were still written to the baseline file.

The flag only affected runtime comparison, not serialization, causing constant merge conflicts in large teams on legacy codebases.
Line numbers are now stripped before saving when --ignore-baseline-linenumbers is passed. No existing behaviour is affected — the fix only applies when both flags are used together.

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.25%. Comparing base (30ad0cc) to head (7c17ca3).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/CLI/Baseline.php 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #621      +/-   ##
============================================
- Coverage     98.29%   98.25%   -0.05%     
- Complexity      696      700       +4     
============================================
  Files            87       87              
  Lines          1991     2000       +9     
============================================
+ Hits           1957     1965       +8     
- Misses           34       35       +1     
Files with missing lines Coverage Δ
src/CLI/Command/Check.php 100.00% <100.00%> (ø)
src/Rules/Violation.php 100.00% <100.00%> (ø)
src/Rules/Violations.php 100.00% <100.00%> (ø)
src/CLI/Baseline.php 93.33% <66.66%> (-3.10%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@micheleorselli micheleorselli 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.

If I got the code right, with this change if a user generates a baseline with --ignore-baseline-linenumbers then every comparison with that baseline would (obviously) ignore line numbers, meaning that if the tool is run with --ignore-baseline-linenumbers or not, it would produce the same result

⚠️ Maybe we should document this behaviour and/or make explicit if the comparison is considering line numbers or not

💭 In my opinion the long term solution should be rethinking the way the baseline works. The user should not be forced to know about line numbers, it should just work. Psalm and PHPStan do use baseline, so we could see how they do it

@AlessandroMinoccheri

Copy link
Copy Markdown
Member Author

I agree @micheleorselli , I would suggest to merge this PR and create a new issue as an IDEA with your vision.
Is it ok for you?
@fain182 what do you think?

@fain182

fain182 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

I think we should add a section in the readme in which document all the configurations...
ignore baseline numbers it seems more like a configuration than an option, because is something persistent.

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.

Ignore line numbers

3 participants