Pass explicit paths to PHPCS even when project has a custom config#207
Open
mhdarffn wants to merge 1 commit into
Open
Pass explicit paths to PHPCS even when project has a custom config#207mhdarffn wants to merge 1 commit into
mhdarffn wants to merge 1 commit into
Conversation
Since 3.4.0, PHP_CodeSniffer ignores any paths the user passes to
`duster lint` / `duster fix` whenever a custom phpcs config exists at
the project root (`.phpcs.xml`, `phpcs.xml`, `.phpcs.xml.dist`,
`phpcs.xml.dist`). The dirty list resolved by `App\Project::paths()` is
correctly stored in `DusterConfig`, but `PhpCodeSniffer::lint()` and
`fix()` short-circuit on `hasCustomConfig()` and call `process()` with
an empty array, so PHPCS falls back to the `<file>` directives in the
ruleset and scans the whole project.
This silently breaks `--dirty` (and `--diff`) for any project that has
a custom phpcs config — every commit re-lints the entire codebase
through pre-commit hooks instead of just the changed files.
Refactors the path resolution into a single `resolvePaths()` helper
with three outcomes:
- `null` — skip PHPCS entirely (e.g. only Blade files
were passed explicitly; preserves PR tighten#199).
- `[]` — defer to the ruleset's `<file>` directives
(no explicit paths, custom config present;
preserves existing 3.4.x behaviour).
- `array<string>` — pass paths through so PHPCS uses them
instead of the ruleset's `<file>` list.
Restores `--dirty` / `--diff` / explicit
`path` argument behaviour for projects with
a custom phpcs config.
Adds a regression test (`it lints only the explicit paths when project
has a custom phpcs config`) and pins the fall-back-to-ruleset
behaviour so it does not regress in future.
Fixes tighten#206
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Since 3.4.0, PHP_CodeSniffer ignores any paths the user passes to
duster lint/duster fixwhenever a custom phpcs config exists at the project root (.phpcs.xml,phpcs.xml,.phpcs.xml.dist,phpcs.xml.dist). The dirty list resolved byApp\Project::paths()is correctly stored inDusterConfig, butPhpCodeSniffer::lint()andfix()short-circuit onhasCustomConfig()and callprocess()with an empty array, so PHPCS falls back to the<file>directives in the ruleset and scans the whole project.This silently breaks
--dirty(and--diff) for any project that has a custom phpcs config — every commit re-lints the entire codebase through pre-commit hooks instead of just the changed files.Refactors the path resolution into a single
resolvePaths()helper with three outcomes:null— skip PHPCS entirely (e.g. only Blade fileswere passed explicitly; preserves PR Manually exclude Blade files from calls to PHPCS #199).
[]— defer to the ruleset's<file>directives(no explicit paths, custom config present;
preserves existing 3.4.x behaviour).
array<string>— pass paths through so PHPCS uses theminstead of the ruleset's
<file>list.Restores
--dirty/--diff/ explicitpathargument behaviour for projects witha custom phpcs config.
Adds a regression test (
it lints only the explicit paths when project has a custom phpcs config) and pins the fall-back-to-ruleset behaviour so it does not regress in future.Fixes #206