php-code-sniffer-baseliner icon indicating copy to clipboard operation
php-code-sniffer-baseliner copied to clipboard

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

Open t0mspace opened this issue 3 years ago • 3 comments

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

t0mspace avatar Jan 07 '22 15:01 t0mspace

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

aphex008 avatar Feb 03 '22 14:02 aphex008

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:

  • phpcs:ignore comments operate on the line level, while <exclude-pattern> directives operate on the file level.
  • Code containing phpcs:ignore comments provide direct feedback whenever a violation is suppressed; this is not the case with <exclude-pattern> tags, which requires a lookup in another file.

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

Aad

aadmathijssen avatar Feb 03 '22 14:02 aadmathijssen

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.

aphex008 avatar Feb 03 '22 15:02 aphex008