Skip to content

Commit 4579a66

Browse files
committed
Merge pull request #72 from loadsys/f/codesniffer-strict-mode
Add -s option to codesniffer-run for "strict" mode.
2 parents 137db9a + 18710b7 commit 4579a66

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

codesniffer-run

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ ${0##*/}
1111
to the standard output.
1212
1313
Usage:
14-
bin/${0##*/} [-f|h|n|x] [-r StndName]|[-r rules.xml] [dirs|files to sniff]
14+
bin/${0##*/} [-f|h|n|s|x] [-r StndName]|[-r rules.xml] [dirs|files to sniff]
1515
1616
f - Write full and summary report out to files.
1717
h - Print this help information.
1818
n - Suppress warnings during the sniff run.
19+
s - Strict mode. Reduces the threshold for WARNINGS, making them
20+
visible for review.
1921
x - Always exit zero regardless of sniff results.
2022
2123
r - Use an explicit ruleset.xml file path or coding standard name.
@@ -55,11 +57,12 @@ SNIFF_FAIL_CAUSES_SCRIPT_FAIL=0 # 0 = true. Script will exit with phpcs's return
5557

5658
SAVE_REPORTS=1 # 1 = false. DON'T save reports when no args provided.
5759
COVERAGE="--report-full --report-summary"
60+
STRICT_MODE=""
5861
SUPPRESS_WARNINGS=""
5962

6063

6164
# Process command line options.
62-
while getopts ":fhnr:x" opt; do
65+
while getopts ":fhnrs:x" opt; do
6366
case $opt in
6467
f)
6568
SAVE_REPORTS=0 # 0 = true. Save reports to files, not print to screen.
@@ -75,6 +78,9 @@ while getopts ":fhnr:x" opt; do
7578
r)
7679
CODE_STANDARD="$OPTARG"
7780
;;
81+
s)
82+
STRICT_MODE="--warning-severity=1"
83+
;;
7884
x)
7985
SNIFF_FAIL_CAUSES_SCRIPT_FAIL=1 # 1 = false. Always exit 0;
8086
;;
@@ -112,7 +118,8 @@ fi
112118

113119
# Run the sniffs.
114120
echo "## Executing code sniffer:"
115-
bin/phpcs -ps $SUPPRESS_WARNINGS \
121+
bin/phpcs -ps $SUPPRESS_WARNINGS $STRICT_MODE \
122+
--colors \
116123
--extensions=php \
117124
--standard="$CODE_STANDARD" \
118125
${COVERAGE} \

0 commit comments

Comments
 (0)