diff options
author | David Spickett <david.spickett@linaro.org> | 2020-04-23 11:10:08 +0100 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2020-04-28 13:13:46 +0000 |
commit | 6273fc478b9c95c4ae8d42c9021f9428b1d43811 (patch) | |
tree | 9564b82cc9e90dc4886835d30cbdea35453b1f53 /sanity-check.sh | |
parent | 0ce72e970e6cbb6c39469b503cdf65510f4f99d8 (diff) |
Shellcheck fixes round 3
Now using the version that's
present in the bionic images.
Meaning we have more warnings
but can also set the minimum
level to ignore a lot of them.
Fix the check for whether
shellcheck supports --severity.
(we have pipefail on, but we
expect shellcheck to fail in
this case)
Change-Id: I296b8554591b7d327c75393e3924184abc6512b7
Diffstat (limited to 'sanity-check.sh')
-rwxr-xr-x | sanity-check.sh | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/sanity-check.sh b/sanity-check.sh index b3c34654..54abb4f3 100755 --- a/sanity-check.sh +++ b/sanity-check.sh @@ -8,26 +8,33 @@ set -euf -o pipefail # ./sanity-check.sh script1.sh script2.sh if [[ "$#" -eq 0 ]]; then - files=($(find "$(dirname "$0")" -name "*.sh" -o -name "*.job")) + files=() + while IFS='' read -r line; do files+=("$line"); done < <(\ + find "$(dirname "$0")" -name "*.sh" -o -name "*.job") else files=("${@}") fi -#TODO: newer versions of shellcheck can set a minimum message level -ignored=( -# All STYLE warnings seen so far --e SC2001 # See if you can use ${variable//search/replace} instead. --e SC2002 # Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. --e SC2004 # $/${} is unnecessary on arithmetic variables. --e SC2006 # Use $(..) instead of legacy `..`. -# All INFO warnings seen so far --e SC2016 # Expressions don't expand in single quotes, use double quotes for that. --e SC2086 # Double quote to prevent globbing and word splitting. --e SC2102 # Ranges can only match single chars (mentioned due to duplicates). --e SC2094 # Make sure not to read and write the same file in the same pipeline. --e SC2029 # Note that, unescaped, this expands on the client side. --e SC2030 # Modification of PATH is local (to subshell caused by (..) group). --e SC2031 # baseline_branch was modified in a subshell. That change might be lost. -) +# New versions can set a minimum level +if (shellcheck 2>&1 || true) | grep -q -- --severity=SEVERITY; then + ignore=(--severity=warning) +else + # Manual list for older versions + ignore=( + # All STYLE warnings seen so far + -e SC2001 # See if you can use ${variable//search/replace} instead. + -e SC2002 # Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. + -e SC2004 # $/${} is unnecessary on arithmetic variables. + -e SC2006 # Use $(..) instead of legacy `..`. + # All INFO warnings seen so far + -e SC2016 # Expressions don't expand in single quotes, use double quotes for that. + -e SC2086 # Double quote to prevent globbing and word splitting. + -e SC2102 # Ranges can only match single chars (mentioned due to duplicates). + -e SC2094 # Make sure not to read and write the same file in the same pipeline. + -e SC2029 # Note that, unescaped, this expands on the client side. + -e SC2030 # Modification of PATH is local (to subshell caused by (..) group). + -e SC2031 # baseline_branch was modified in a subshell. That change might be lost. + ) +fi -shellcheck "${files[@]}" "${ignored[@]}" +shellcheck "${files[@]}" "${ignore[@]}" |