Skip to content

Commit

Permalink
Merge pull request #72 from loadsys/f/codesniffer-strict-mode
Browse files Browse the repository at this point in the history
Add -s option to codesniffer-run for "strict" mode.
  • Loading branch information
beporter committed Feb 2, 2016
2 parents 137db9a + 18710b7 commit 4579a66
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions codesniffer-run
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ ${0##*/}
to the standard output.
Usage:
bin/${0##*/} [-f|h|n|x] [-r StndName]|[-r rules.xml] [dirs|files to sniff]
bin/${0##*/} [-f|h|n|s|x] [-r StndName]|[-r rules.xml] [dirs|files to sniff]
f - Write full and summary report out to files.
h - Print this help information.
n - Suppress warnings during the sniff run.
s - Strict mode. Reduces the threshold for WARNINGS, making them
visible for review.
x - Always exit zero regardless of sniff results.
r - Use an explicit ruleset.xml file path or coding standard name.
Expand Down Expand Up @@ -55,11 +57,12 @@ SNIFF_FAIL_CAUSES_SCRIPT_FAIL=0 # 0 = true. Script will exit with phpcs's return

SAVE_REPORTS=1 # 1 = false. DON'T save reports when no args provided.
COVERAGE="--report-full --report-summary"
STRICT_MODE=""
SUPPRESS_WARNINGS=""


# Process command line options.
while getopts ":fhnr:x" opt; do
while getopts ":fhnrs:x" opt; do
case $opt in
f)
SAVE_REPORTS=0 # 0 = true. Save reports to files, not print to screen.
Expand All @@ -75,6 +78,9 @@ while getopts ":fhnr:x" opt; do
r)
CODE_STANDARD="$OPTARG"
;;
s)
STRICT_MODE="--warning-severity=1"
;;
x)
SNIFF_FAIL_CAUSES_SCRIPT_FAIL=1 # 1 = false. Always exit 0;
;;
Expand Down Expand Up @@ -112,7 +118,8 @@ fi

# Run the sniffs.
echo "## Executing code sniffer:"
bin/phpcs -ps $SUPPRESS_WARNINGS \
bin/phpcs -ps $SUPPRESS_WARNINGS $STRICT_MODE \
--colors \
--extensions=php \
--standard="$CODE_STANDARD" \
${COVERAGE} \
Expand Down

0 comments on commit 4579a66

Please sign in to comment.