Adding support of passing project-specific configuration to code sniffer
Now phpdebt can be allowed to use the PHPCS config via:
phpdebt <path-of-dir/file-to-be-scanned> --standard=phpcs.xml.dist
Is there a solution for scanning multiple paths, or does that still need to be discussed?
If you use --standard, the paths that phpcs scans are defined in that file, so you could have it scan web/modules/custom and web/themes/custom. The path, which is still required, would just be used for phpmd.
Example 1, the standard configures phpcs to scan two places:
# Scans two places with phpmd, but runs phpcs a second time for nothing.
$ phpdebt web/modules/custom --standard=phpcs.xml
$ phpdebt web/themes/custom --standard=phpcs.xml
Example 2, use two standards, one that just includes modules and one that just includes the theme:
# Requires invoking phpdebt twice, same as it does currently, but you need two standards, each matching the path we give to phpdebt.
$ phpdebt web/modules/custom --standard=phpcs-modules.xml
$ phpdebt web/themes/custom --standard=phpcs-theme.xml
I looked at a project that uses a custom phpcs configuration, and it looks like there's a potential additional problem. It sounds like phpcs only uses the paths specified in the standard if there isn't a path given on the command line. Perhaps it'd be more intuitive if the path given to phpdebt would also override the paths in the standard. The CI scripts we'd have to write would be like Example 1, except that the paths scanned would be the path we see in the command line.
@travis-bradbury, I've updated the code and it'll be using now the format of Example 1. I also found it more logical, thanks for the explanation with examples.
phpdebt <the-path> --standard=phpcs.xml.dist, now if this command is passed, then <the-path> will be used for phpcs just like phpmd & the rest configuration will be consumed by phpcs.xml.dist.
@RishiKulshreshtha cool, looks good to me now.
@RishiKulshreshtha can you give me a quick summary of this PR? It looks like it switches the setup to use symfony console as the base and then moves some of the phpdebt commands into that?
can you give me a quick summary of this PR?
@smmccabe, as added above:
Using this, phpdebt can be allowed to use the PHPCS config via: phpdebt <path-of-dir/file-to-be-scanned> --standard=phpcs.xml.dist
It looks like it switches the setup to use symfony console as the base and then moves some of the phpdebt commands into that?
Yes, that's correct, but the actual reason to implement this is to allow the user/dev to use their existing/custom phpcs.xml.dist while calling the phpdebt. If provided then the values provided at the phpcs.xml.dist will be prioritized over the defaults of the phpdebt config.