Skip to content

Commit cc33984

Browse files
authored
Merge pull request #2 from PHPCSStandards/feature/add-sniff-feature-complete-script
New feature: script to check that sniffs are "feature complete"
2 parents bfc4899 + 50a18a2 commit cc33984

7 files changed

Lines changed: 669 additions & 0 deletions

File tree

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ before_install:
5454

5555

5656
script:
57+
# Lint PHP files against parse errors.
58+
- composer lint
59+
5760
# Validate the composer.json file on low/high PHP versions.
5861
# @link https://getcomposer.org/doc/03-cli.md#validate
5962
- composer validate --no-check-all --strict

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This is a set of tools to aid developers of sniffs for [PHP CodeSniffer](https:/
2323
+ [Composer Global Installation](#composer-global-installation)
2424
+ [Stand-alone Installation](#stand-alone-installation)
2525
* [Features](#features)
26+
+ [Checking whether all sniffs in a PHPCS standard are feature complete](#checking-whether-all-sniffs-in-a-phpcs-standard-are-feature-complete)
2627
+ [PHPCSDev ruleset for sniff repos](#phpcsdev-ruleset-for-sniff-repos)
2728
* [Contributing](#contributing)
2829
* [License](#license)
@@ -64,6 +65,52 @@ composer global require phpcsstandards/phpcsdevtools:^1.0
6465
Features
6566
------------------------------
6667

68+
### Checking whether all sniffs in a PHPCS standard are feature complete
69+
70+
You can now easily check whether each and every sniff in your standard is accompanied by a documentation XML file (warning) as well as unit test files (error).
71+
72+
To use the tool, run it from the root of the your standards repo like so:
73+
```bash
74+
# When installed as a project dependency:
75+
vendor/bin/phpcs-check-feature-completeness
76+
77+
# When installed globally with Composer:
78+
phpcs-check-feature-completeness
79+
80+
# When installed as a git clone or otherwise:
81+
php -f "path/to/PHPCSDevTools/bin/phpcs-check-feature-completeness"
82+
```
83+
84+
If all is good, you will see a `All # sniffs are accompanied by unit tests and documentation.` message.
85+
86+
If there are files missing, you will see errors/warnings for each missing file, like so:
87+
```
88+
WARNING: Documentation missing for path/to/project/StandardName/Sniffs/Category/SniffNameSniff.php.
89+
ERROR: Unit tests missing for path/to/project/StandardName/Sniffs/Category/SniffNameSniff.php.
90+
```
91+
92+
For the fastest results, it is recommended to pass the name of the subdirectory where your standard is located to the script, like so:
93+
```bash
94+
phpcs-check-feature-completeness ./StandardName
95+
```
96+
97+
#### Options
98+
```
99+
directories One or more specific directories to examine.
100+
Defaults to the directory from which the script is run.
101+
-q, --quiet Turn off warnings for missing documentation.
102+
--exclude Comma-delimited list of (relative) directories to exclude
103+
from the scan.
104+
Defaults to excluding the /vendor/ directory.
105+
--no-progress Disable progress in console output.
106+
--colors Enable colors in console output.
107+
(disables auto detection of color support)
108+
--no-colors Disable colors in console output.
109+
-h, --help Print this help.
110+
-V, --version Display the current version of this script.
111+
```
112+
113+
67114
### PHPCSDev ruleset for sniff repos
68115

69116
Once this project is installed, you will see a new `PHPCSDev` ruleset in the list of installed standards when you run `phpcs -i`.

0 commit comments

Comments
 (0)