Closed shelane closed 5 years ago
@shelane, can you give me some more detail on what you expect to get from them and what you're seeing them do? Those commands should be doing exactly what you describe. You're a few releases behind current but I can't immediately think of significant changes that have been made to those commands in the interim.
blt tests:phpcs:sniff:all
literally sniffs everything. I am working with one custom module, so "everything" can be too much when there are many files that have issues.
fin blt tests:phpcs:sniff:files "/var/www/docroot/modules/custom/sharing"
Returns this:
Sniffing directories containing changed files...
[File\Write] Writing to /var/www/tmp/phpcs-fileset.
[ExecStack] '/var/www/vendor/bin/phpcs' --file-list='/var/www/tmp/phpcs-fileset' --bootstrap='/var/www/vendor/acquia/blt/src/Robo/Commands/Validate/phpcs-validate-files-bootstrap.php' -l
I expected to see the same output that I did from running "all" so I'm not sure if it's not accepting the file path or what it's doing. I checked the tmp directory, but there is nothing there.
Is that the entirety of the output of sniff:files
? When I have it scan a directory with no errors, what I get is below.
$ blt tests:phpcs:sniff:files "docroot/modules/custom/fnord"
[warning] Drupal VM is locally initialized, but is not running.
Sniffing directories containing changed files...
[File\Write] Writing to /Users/barrett.smith/Desktop/newblt/tmp/phpcs-fileset.
[ExecStack] '/Users/barrett.smith/Desktop/newblt/vendor/bin/phpcs' --file-list='/Users/barrett.smith/Desktop/newblt/tmp/phpcs-fileset' --bootstrap='/Users/barrett.smith/Desktop/newblt/vendor/acquia/blt/src/Robo/Commands/Validate/phpcs-validate-files-bootstrap.php' -l
.
Time: 49ms; Memory: 6Mb
$
What I notice is that it's not traversing directories within the path I gave it. In my example, I have a directory inside fnord
which I know contains bad syntax (which with sniff:all
flags), but as you can see sniff:files
didn't flag it.
What you might do to scan all the files in a single module is to edit your phpcs.xml.dist
in your repo root and change the <file>docroot/modules/custom</file>
line to <file>docroot/modules/custom/sharing</file>.
Not a permanent fix, but might be a decent enough workaround while you focus on that module.
Yes, that was the full output and that directory of files did have issues according to sniff:all, but like yours, is not traversing into files in directories inside of the listed directory.
@shelane did the solution of editing your phpcs.xml.dist
provide a suitable workaround?
I did not attempt that work around. I had only a few other files that were coming up in the scan, so I fixed the issues in those files.
Dupe of #3448
My system information:
Output of
blt doctor
:I want to be able to run a code "sniff" and a code "fix" (phpcs/phpcbf) on either a path where all the files in the path would be checked/fixed or a single file. Looking through the list of commands, I find:
tests:phpcs:sniff:all
andtests:phpcs:sniff:files
but it's not clear what they are doing and they aren't doing what I would want.