Automattic / vip-go-compatibility-scanner

Scan for compatibility problems in repository code using PHPCS with any standard, report as GitHub issues.
5 stars 1 forks source link

PHP Compatibility config file #12

Closed andrewfleming closed 3 years ago

andrewfleming commented 4 years ago

Are we able to provide a config file for the PHPCompatibilityWP where we can define exclusions or rules? I see this addressing false-positives so they don't continue to be flagged. See this issue for an example https://github.com/Automattic/vip-go-mu-plugins/issues/1851#issuecomment-727950607

gudmdharalds commented 4 years ago

Of course!

Here is a ruleset file I created: https://github.com/Automattic/vip-go-compatibility-scanner/blob/master/php-7.4-upgrade-ruleset.xml

Using this file to scan is easy:

./compatibility-scanner.php ... --phpcs-standard=$HOME/vip-go-ci-tools/vip-go-compatibility-scanner/php-7.4-upgrade-ruleset.xml

Does this look good? If so, I will add it to the README.md

andrewfleming commented 4 years ago

Thanks for showing how this is achieved @gudmdharalds 🙂 I'm reading the Annotated Ruleset and I understand that the exclusion currently in vip-go-compatibility-scanner/php-7.4-upgrade-ruleset.xml will exclude the rule from all files scanned. This exclusion feels to broad.

How can we exclude the rule from the a specific file?

gudmdharalds commented 4 years ago

How can we exclude the rule from the a specific file?

I think this would have to be done with vip-go-compatibility-scanner itself: We could create an exclusions-file whereby we specify rules to skip when specific files are scanned. For example:

{"file1.php":"PHPCompatibility.ParameterValues.NewIDNVariantDefault.NotSet","file2.php":"PHPCompatibility.OtherRule.Rule1"}

In this case, PHPCompatibility.ParameterValues.NewIDNVariantDefault.NotSet is skipped for files named file1.php and PHPCompatibility.OtherRule.Rule1 for files named file2.php. It would be possible to specify more than one rule per file. The matching would be on file-name basis but we could use a relative path too.

andrewfleming commented 3 years ago

😕 A custom exclusion file feels to me like it's moving too far from how PHPCS was designed to work. I'm happy or the team to review and identify false-positives manually for now. Marking as closed.