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

Add false positives warning #7

Closed
peterjaap opened this issue Nov 16, 2022 · 3 comments
Closed

Add false positives warning #7

peterjaap opened this issue Nov 16, 2022 · 3 comments

Comments

@peterjaap
Copy link

peterjaap commented Nov 16, 2022

Is your feature request related to a problem? Please describe.
After fixing an error for which a baseline entry exists, and running phpcs, nothing happens. There's no difference in output.

Describe the solution you'd like
I would like to receive a warning or error from this tool saying that even though I fixed the phpcs error, the baseline entry is still there in phpcs.baseline.xml.

Because right now, when somebody re-introduces the original error, it would not trigger a phpcs error/warning because it is still in the baseline, causing a false positive (or an unmatched ignored error).

Describe alternatives you've considered
No alternative

Additional context
PHPStan supports this ootb, it's the reportUnmatchedIgnoredErrors parameter, see https://phpstan.org/user-guide/baseline

@peterjaap peterjaap changed the title Add unmatched ignored errors warning Add false positives warning Nov 20, 2022
@peterjaap
Copy link
Author

Hmm harder than I originally thought because of how this works - it looks for an entry in the baseline when it encounters an error/warning. So when the error/warning is fixed, there is nothing that triggers a search for it in the baseline.

So we should keep track of all "matched" baselines, and throw warnings on unmatched ones.

@peterjaap
Copy link
Author

Hmm and that is exactly the part that gets injected into the phpcs code, no nice clean API for that unfortunately.

@peterjaap
Copy link
Author

As far as I can see, we can't do this in just this package. We'd need more hacking in phpcs and that's not worth it.

We'll just have to wait for squizlabs/PHP_CodeSniffer#3387 to be merged and we can add it there (if it's not part of the eventual code that'll get merged).

Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant