summaryrefslogtreecommitdiff
path: root/sanity-check.sh
blob: 1a3da79c18878c77d76f29e6431264384af8ce98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -euf -o pipefail

# Usage:
# Check all scripts in this folder:
# ./sanity-check.sh
# Check specific files:
# ./sanity-check.sh script1.sh script2.sh

if [[ "$#" -eq 0 ]]; then
  files=($(find "$(dirname "$0")" -name "*.sh"))
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.
)

shellcheck "${files[@]}" "${ignored[@]}"