fix(phpcs): exclude vendor/ from ruleset to silence third-party errors#271
Open
faisalahammad wants to merge 1 commit into
Open
fix(phpcs): exclude vendor/ from ruleset to silence third-party errors#271faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Issue 10up#251 reports that running phpcs on the repo flags errors in vendor/nikic/php-parser and vendor/hamcrest/hamcrest-php on PHP 8.2+. Those libraries are transitive dependencies pinned by other dev packages; the project does not own their source. Harden the phpcs.xml ruleset so vendor is never scanned regardless of how phpcs is invoked. Also switch testVersion from the exact '7.4' to the open range '7.4-' so the standard targets the minimum supported PHP and above, matching PHPCompatibility conventions. Fixes 10up#251
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #251.
Running phpcs in the repo currently reports errors in third-party dependencies (
nikic/php-parser,hamcrest/hamcrest-php) on PHP 8.2+. Those libraries are transitive dependencies pinned by other dev packages, and the project does not own their source.This PR hardens the phpcs.xml ruleset so vendor is never scanned regardless of how phpcs is invoked, and switches
testVersionfrom exact7.4to the open range7.4-so the standard targets the minimum supported PHP and above.Changes
phpcs.xml
Before:
After:
Why: The original ruleset only restricted scan paths. When phpcs is invoked with a path that includes vendor (or with the project root as a default), third-party code gets scanned and reported. Excluding vendor in the ruleset is the standard PHPCS idiom for "scan only project source". The open-range
testVersionmatches PHPCompatibility conventions (per their README example) and ensures the standard targets the minimum supported PHP and above.Testing
Test 1: Default scan (the CI command)
composer installvendor/bin/phpcsResult: 43 files scanned in
./phpand./tests, all clean. No vendor noise.Test 2: Scan project root with the project ruleset
vendor/bin/phpcs .Result: 46 files scanned (43 above plus 3 config files in
.), all clean. No vendor noise.Test 3: Reproduce the original report
vendor/bin/phpcs --runtime-set testVersion 8.2- .Result: only project files are scanned. No errors from
vendor/nikic/php-parserorvendor/hamcrest/hamcrest-php.Test 4: Full test suite
composer test:phpunitResult: 160 tests, 1 skipped (pre-existing final-class limitation on PHP 7.4, unrelated to this change).