Skip to content

Commit 0b5b97c

Browse files
authored
Load shellcheck configuration from the .shellcheckrc (#1840)
1 parent a5fb2d6 commit 0b5b97c

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

‎.shellcheckrc‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# shellcheck configuration file
2+
# see: https://github.com/koalaman/shellcheck/wiki
3+
4+
# Allow following sourced files that are not specified in the command,
5+
# we need this because we specify one file at a time in order to trivially
6+
# detect which files are failing
7+
external-sources=true
8+
9+
# Currently disabled these errors will take care of them later
10+
11+
# Not following: (error message here)
12+
# https://github.com/koalaman/shellcheck/wiki/SC1091
13+
disable=SC1091
14+
# Since you double quoted this, it will not word split, and the loop will only run once
15+
# https://github.com/koalaman/shellcheck/wiki/SC2066
16+
disable=SC2066
17+
# Double quote to prevent globbing and word splitting
18+
# https://github.com/koalaman/shellcheck/wiki/SC2086
19+
disable=SC2086
20+
# foo appears unused. Verify it or export it
21+
# https://github.com/koalaman/shellcheck/wiki/SC2034
22+
disable=SC2034
23+
# This {/} is literal. Check if ; is missing or quote the expression.
24+
# https://github.com/koalaman/shellcheck/wiki/SC1083
25+
disable=SC1083
26+
# Declare and assign separately to avoid masking return values
27+
# https://github.com/koalaman/shellcheck/wiki/SC2155
28+
disable=SC2155
29+
# Quote this to prevent word splitting
30+
# https://github.com/koalaman/shellcheck/wiki/SC2046
31+
disable=SC2046

‎hack/verify-shellcheck.sh‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ DOCKER="${DOCKER:-docker}"
2121
SHELLCHECK_VERSION="0.9.0"
2222
SHELLCHECK_IMAGE="docker.io/koalaman/shellcheck-alpine:v0.9.0@sha256:e19ed93c22423970d56568e171b4512c9244fc75dd9114045016b4a0073ac4b7"
2323

24-
SHELLCHECK_DISABLED="SC2002,SC3028,SC3054,SC3014,SC3040,SC3046,SC3030,SC3010,SC3037,SC3045,SC3006,SC3018,SC3016,SC3011,SC3044,SC3043,SC3060,SC3024,SC1091,SC2066,SC2086,SC2034,SC1083,SC1009,SC1073,SC1072,SC2155,SC2046"
25-
# common arguments we'll pass to shellcheck
26-
SHELLCHECK_OPTIONS=(
27-
# allow following sourced files that are not specified in the command,
28-
# we need this because we specify one file at a time in order to trivially
29-
# detect which files are failing
30-
"--external-sources"
31-
# include our disabled lints
32-
"--exclude=${SHELLCHECK_DISABLED}"
33-
# set colorized output
34-
"--color=${SHELLCHECK_COLORIZED_OUTPUT}"
35-
)
36-
37-
# Currently disabled these errors will take care of them later
38-
3924
scripts_to_check=("$@")
4025
if [[ "$#" == 0 ]]; then
4126
# Find all shell scripts excluding:
@@ -60,11 +45,12 @@ fi
6045
echo "Downloading ShellCheck Docker image..."
6146
"${DOCKER}" pull "${SHELLCHECK_IMAGE}"
6247

63-
# Run ShellCheck on all shell script files, excluding those in the 'vendor' directory
48+
# Run ShellCheck on all shell script files, excluding those in the 'vendor' directory.
49+
# Configuration loaded from the .shelcheckrc file.
6450
echo "Running ShellCheck..."
6551
"${DOCKER}" run \
6652
--rm -v "$(pwd)" -w "$(pwd)" \
6753
"${SHELLCHECK_IMAGE}" \
68-
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${scripts_to_check[@]}" >&2 || res=$?
54+
shellcheck "--color=${SHELLCHECK_COLORIZED_OUTPUT}" "${scripts_to_check[@]}" >&2 || res=$?
6955

7056
echo "Shellcheck ran successfully"

0 commit comments

Comments
 (0)