isaaceindhoven / php-code-sniffer-baseliner

Baseline tool for PHP_CodeSniffer
https://isaac.nl
MIT License
16 stars 5 forks source link

add the possibility to use a dedicated file to list the baseline #8

Open t0mspace opened 2 years ago

t0mspace commented 2 years ago

Hi Isaac,

It would be great to offer the possibility to generate a file with all the baseline like do phpstan, instead of writing it in the source code

Thanks by advance and respect for your work

Tom

aphex008 commented 2 years ago

Count my vote for this feature. As an example - Phpstan has very usable implementation.

aadmathijssen commented 2 years ago

Hi,

The first (internal) version of this tool added a list of rule-specific <exclude-pattern> tags to the phpcs.xml. We ultimately switched to inline phpcs:ignore comments for the following reasons:

I hope this clarifies our reasons for the way in which the tool is currently implemented.

Aad

aphex008 commented 2 years ago

Hello @aadmathijssen Thank you for reaching out!

As I understand with phpcs baseliner phpcs:ignore istatements would be added in the code. So if for example rule causing the warning would be removed or issue fixed manually - ignore statements would still remain in codebase until manually removed. No warning about redundant ignores would fire.

That means there is no way of knowing that ignore statement is no longer relevant.

I'll try to explain my workflow by using phpstan as an example. When baseline is created all issues are written to the file and ignored while checking code. If code has ben fixed or rules of phpstan have been changed in a way that makes excludes obsolete - phpstan throws exception that issues mentioned in the baseline are no longer present. To fix this I remove no longer valid lines from baseline file by running an update command. So there is no need for manual changes to remove no longer relevant ignores.

Please correct me if I don't understand usage of the library correctly.