Commit 4e045f2
committed
✨ New feature: script to check that sniffs are "feature complete"
This adds a custom script which will check whether each and every sniff is accompanied by a documentation XML file (warning) as well as unit test files (error).
The script will be available in the Composer `vendor/bin` directory as `phpcs-check-feature-completeness`.
Notes:
* To only show errors, the script can be run in `quiet` mode by passing the `-q` flag on the command line.
See the included documentation in the `README.md` file for other available options.
* The script has been set up in such a way that it can both be used by PHPCS itself, as well as by external standards which use the PHPCS native unit test suite.
To use the tool, run it from the root of the external standards repo like so:
`vendor/bin/phpcs-check-feature-completeness`
or when not installed via Composer:
`php -f "path/to/PHPCSDevTools/bin/phpcs-check-feature-completeness"`
* The list of sniffs to check completeness for is determined by getting a list of all files in `Sniffs` directories, where the files have a name ending with `Sniff.php` and not prefixed with `Abstract`.
* The "has tests" check verifies that a `UnitTest.php` file is present for each sniff in the standard's `Tests` directory and _at least_ one test case file.
* The "has docs" check verifies that a `Standard.xml` file is present for each sniff in the standard's `Docs` directory.
When implementing this check in CI, it only needs to be run on one build as the results won't change between PHP versions.
An earlier version of this script was originally pulled to PHPCS itself in PR 2364.1 parent bfc4899 commit 4e045f2
6 files changed
Lines changed: 666 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
67 | 114 | | |
68 | 115 | | |
69 | 116 | | |
| |||
0 commit comments