Closed lems3 closed 1 year ago
Weird. This could have been a regression in the refactors from 2.11. I'll see what I can fix.
Oh, this is actually worse than the one issue! Since creating CliOptions
runs that validation, it also breaks other commands like phpcs-changed -i
.
For now I do a git diff --names-only and feed it to the command. Woth the --git and --git-base flags it works really nice.
It may be a bit more efficient for us as our codebase have a lot of files. 😂
https://github.com/sirbrillig/phpcs-changed/pull/95 should fix this.
Version : phpcs-changed version 2.11.2
Steps to reproduce :
phpcs-changed --git --git-base main settings
This is the stack trace I get :
Meanwhile, running
phpcs-changed --git --git-base main settings/settings.php
works.My goal would be to run this on our pull requests and see if the code changes follows our PHP CS rules.
Using a glob doesn't fix the issue either.
After a bit of diggint, I found that :
In the bin/phpcs-changed file, while iterating the list of files and folder, you use
CliOptions::fromArray($options)
to validate file extensions for files. But at that moment thefiles
index of the$options
array is empty, since we're still building up the file list.I did some changes in the code to hardcode a first valid value in the
$options["files"]
index, and now passing folders to the command line works.