Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore line endings & whitespace in baseline code snippets #6000

Merged
merged 4 commits into from
Jun 27, 2021

Conversation

bdsl
Copy link
Contributor

@bdsl bdsl commented Jun 26, 2021

This change makes Psalm trim code snippets read from the baseline, and the snippets from issues found in the current analysis, so that the comparison won't care whether either of them has any carriage return character, or any other type of white space at the start or end.

Should fix #5979

@bdsl bdsl force-pushed the ignore-line-endings-in-baseline branch from f9b1aa5 to 3097bcc Compare June 26, 2021 21:00
@bdsl bdsl changed the title Simplify lots of usage checks Ignore line endings & whitespace in baseline code snippets Jun 26, 2021
@bdsl bdsl force-pushed the ignore-line-endings-in-baseline branch from 5d505b3 to ee00c23 Compare June 26, 2021 21:30
…t baseline

Should fix issue vimeo#5979

We could also trim code issues when writing to baseline, but I think
that's a minor BC break, so probably shouldn't happen until Psalm 9.
@bdsl bdsl force-pushed the ignore-line-endings-in-baseline branch from ee00c23 to 0722401 Compare June 26, 2021 21:37
@bdsl
Copy link
Contributor Author

bdsl commented Jun 26, 2021

I have tested this manually by applying this patch - the current version of Psalm reports an Error when run on itself with the patch applied. The version from this PR reports 'no errors found'.

I don't think this needs an automated end-to-end test.

0001-add-carrige-return-to-issue-in-baseline.patch

From b0dcbef6bbdfca1b0017002678cefbb3750f94f9 Mon Sep 17 00:00:00 2001
From: Barney Laurance <[email protected]>
Date: Sat, 26 Jun 2021 22:33:25 +0100
Subject: [PATCH] add-carrige-return-to-issue-in-baseline

---
 psalm-baseline.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 67e00699f..687294a95 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -2,7 +2,7 @@
 <files psalm-version="dev-master@5e8219b613d9f97cd7eeba16e1fea75cc8a808e6">
   <file src="examples/TemplateChecker.php">
     <PossiblyUndefinedIntArrayOffset occurrences="2">
-      <code>$comment_block-&gt;tags['variablesfrom'][0]</code>
+      <code>$comment_block-&gt;tags['variablesfrom'][0]&#13;</code>
       <code>$matches[1]</code>
     </PossiblyUndefinedIntArrayOffset>
   </file>
-- 
2.30.2

@bdsl bdsl marked this pull request as ready for review June 26, 2021 21:42
@bdsl
Copy link
Contributor Author

bdsl commented Jun 26, 2021

6k !!!!

tests/IssueBufferTest.php Outdated Show resolved Hide resolved
@bdsl bdsl force-pushed the ignore-line-endings-in-baseline branch from 5bdb6ce to 140cf01 Compare June 27, 2021 09:36
@weirdan weirdan merged commit 8c13752 into vimeo:master Jun 27, 2021
@weirdan
Copy link
Collaborator

weirdan commented Jun 27, 2021

Thanks!

@bdsl bdsl deleted the ignore-line-endings-in-baseline branch June 27, 2021 13:12
weirdan added a commit to weirdan/psalm that referenced this pull request Jan 3, 2022
@weirdan weirdan mentioned this pull request Jan 3, 2022
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 ending characters when matching code issues against baseline
2 participants