Add cwd to codesniffer paths - #218
Conversation
|
Thanks for tracking this down! The fix is right in spirit, but the Windows CI failures come from the separator handling. TL;DR: We need to convert everything to Mac-style on Windows machines, and let PHPCS handle conversions for us. Longer story, with the aide of my buddy Claude for writing it out more fully: PHPCS treats each The key detail is that PHPCS expects // We assume a / directory separator, as do the exclude rules
// most developers write, so we need a special case for any system that is different.
if (DIRECTORY_SEPARATOR === '\\') {
$replacements['/'] = '\\\\';
}So the pattern should always use forward slashes, and $cwd = str_replace('\\', '/', getcwd());
$ignore = $this->dusterConfig->get('exclude')
? ['--ignore=' . implode(',',
array_map(fn ($path) => str_contains($path, $cwd) ? $path : $cwd . '/*' . $path, $this->dusterConfig->get('exclude')))]
: [];i.e. drop |
That one was unexpected, thanks for the tip! Confirmed to still work on my device (unfortunately i have no windows device to test on) |
|
Tests are now succeeding! I've also added 2 small tests to check that it actually lints in |
Fixes: #201
PHP_CodeSniffer uses regex in their
--ignorelist transforming*into.*Thus we can prefix
<cwd>/*for all ignore rules to ensure the main folder is ignored.Running the original duster before these changes on a repo without
/build/in the project pathRunning the original duster before these changes on a repo with
/build/in the project pathRunning the changed duster on a repo with
/build/in the repo pathSince only PHP_CodeSniffer complains and i am certain how it handles ignores i am only applying it there.
with build in the project path Tlint, PHP CS Fixer, and Pint all give feedback. Only PHP_CodeSniffer gave these issues