[Repo Assist] fix: align configSearch file priority with PHP_CodeSniffer's auto-detection order#137
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…-detection order The confFileNames array had .phpcs.xml.dist before phpcs.xml, but PHP_CodeSniffer itself searches in this order: .phpcs.xml > phpcs.xml > .phpcs.xml.dist > phpcs.xml.dist This only matters when a project has two different config files in the same directory (e.g. both phpcs.xml and .phpcs.xml.dist), but the extension was silently choosing the wrong one. Fix: reorder to match PHPCS Config.php: https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/src/Config.php Also adds 3 new unit tests that document and lock in the correct priority. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
66 tasks
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.
🤖 This is an automated draft PR from Repo Assist.
Problem
The
confFileNamesarray ingetStandard()had its entries in the wrong order relative to what PHP_CodeSniffer itself uses when auto-detecting ruleset files.Extension's previous order:
The bug:
.phpcs.xml.distwas placed beforephpcs.xml. This means if a project had both.phpcs.xml.dist(a distribution template) andphpcs.xml(the actual project config) in the same directory, the extension would pass.phpcs.xml.distto--standard=instead ofphpcs.xml.Fix
Reorder
confFileNamesto match PHPCS's own priority:node --check extension.js: OK ✅No CI workflow exists in this repository; all checks are manual.
Impact
This is an edge-case fix — it only affects users who have multiple config files in the same directory (e.g. a project with both
.phpcs.xml.distchecked in as a template andphpcs.xmlas the active config). For everyone else, the behaviour is unchanged.Relates to #17 (extension ignores phpcs.xml).