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

Ignored error on removed file doesn't trigger error unless cache is emptied #3058

Closed
Daeroni opened this issue Mar 4, 2020 · 3 comments
Closed

Comments

@Daeroni
Copy link
Contributor

Daeroni commented Mar 4, 2020

Bug report

If an error was ignored with a baseline, and then the file containing the error, phpstan doesn't notice that the error is not matched anymore because it doesn't analyze deleted files (obviously).

When cache is deleted, the error about unmatched error is shown.

Code snippet that reproduces the problem

$ echo '<?php print "abc";' > ok.php
$ echo '<?php print "abc" + 1;' > notok.php
$ /path/to/phpstan/bin/phpstan analyze --error-format=baselineNeon --level 8 . | tee phpstan-baseline.neon
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

parameters:
        ignoreErrors:
                -
                        message: "#^Binary operation \"\\+\" between 'abc' and 1 results in an error\\.$#"
                        count: 1
                        path: notok.php

$ echo -e "includes:\n    - phpstan-baseline.neon" > phpstan.neon
$ /path/to/phpstan/bin/phpstan analyze -c phpstan.neon --level 8 .
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%



 [OK] No errors


$ rm notok.php
$ /path/to/phpstan/bin/phpstan analyze -c phpstan.neon --level 8 .
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%



 [OK] No errors


$ rm -rf /tmp/phpstan/
$ /path/to/phpstan/bin/phpstan analyze -c phpstan.neon --level 8 .
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 -- ---------------------------------------------------------------------------------------------------
     Error
 -- ---------------------------------------------------------------------------------------------------
     Ignored error pattern #^Binary operation "\+" between 'abc' and 1 results in an error\.$# in path
     /home/teemu/phpstantest/ignored_error/notok.php was not matched in reported errors.
 -- ---------------------------------------------------------------------------------------------------


 [ERROR] Found 1 error

Expected output

Error about ignored error not matched should be shown when running phpstan after deleting a file with an ignored error.

@mergeable
Copy link

mergeable bot commented Mar 4, 2020

This bug report is missing a link to reproduction on phpstan.org.
It will most likely be closed after manual review.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@9e10b4c

@lock
Copy link

lock bot commented Apr 17, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
BTW: Did you know that PHPStan now has a brand new website with a user guide, guide to writing analyser-friendly PHP code, and a guide to developing PHPStan extensions? Visit phpstan.org today!

@lock lock bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants