Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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