Skip to content

Commit fe0ff56

Browse files
committed
test: Enable SC2046 shellcheck rule
1 parent 9a1ad7b commit fe0ff56

File tree

10 files changed

+17
-13
lines changed

10 files changed

+17
-13
lines changed

ci/lint/04_install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export LC_ALL=C
88

99
${CI_RETRY_EXE} apt-get update
1010
${CI_RETRY_EXE} apt-get install -y clang-format-9 python3-pip curl git gawk jq
11-
update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-9 ) 100
12-
update-alternatives --install /usr/bin/clang-format-diff clang-format-diff $(which clang-format-diff-9) 100
11+
update-alternatives --install /usr/bin/clang-format clang-format "$(which clang-format-9 )" 100
12+
update-alternatives --install /usr/bin/clang-format-diff clang-format-diff "$(which clang-format-diff-9)" 100
1313

1414
${CI_RETRY_EXE} pip3 install codespell==2.0.0
1515
${CI_RETRY_EXE} pip3 install flake8==3.8.3

ci/lint/06_script.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; t
3131
# sanity checking only a few (10) commits seems sufficient and cheap.
3232
git log HEAD~10 -1 --format='%H' > ./contrib/verify-commits/trusted-sha512-root-commit
3333
git log HEAD~10 -1 --format='%H' > ./contrib/verify-commits/trusted-git-root
34-
${CI_RETRY_EXE} gpg --keyserver hkps://keys.openpgp.org --recv-keys $(<contrib/verify-commits/trusted-keys) &&
34+
mapfile -t KEYS < contrib/verify-commits/trusted-keys
35+
${CI_RETRY_EXE} gpg --keyserver hkps://keys.openpgp.org --recv-keys "${KEYS[@]}" &&
3536
./contrib/verify-commits/verify-commits.py;
3637
fi
3738

ci/test/04_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ if [ "$CI_OS_NAME" == "macos" ]; then
8282
else
8383
DOCKER_EXEC free -m -h
8484
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
85-
DOCKER_EXEC echo $(lscpu | grep Endian)
85+
DOCKER_EXEC echo "$(lscpu | grep Endian)"
8686
fi
8787
DOCKER_EXEC echo "Free disk space:"
8888
DOCKER_EXEC df -h

ci/test/wrap-qemu.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/minisketch/test{,-verify},src/univalue/{no_nul,test_json,unitester,object}}; do
1010
# shellcheck disable=SC2044
11-
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name $(basename "$b_name")); do
11+
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
1212
echo "Wrap $b ..."
1313
mv "$b" "${b}_orig"
1414
echo '#!/usr/bin/env bash' > "$b"

ci/test/wrap-valgrind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
for b_name in "${BASE_OUTDIR}/bin"/*; do
1010
# shellcheck disable=SC2044
11-
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name $(basename "$b_name")); do
11+
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
1212
echo "Wrap $b ..."
1313
mv "$b" "${b}_orig"
1414
echo '#!/usr/bin/env bash' > "$b"

contrib/windeploy/detached-sig-create.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ TIMESERVER=http://timestamp.comodoca.com
2323
CERTFILE="win-codesign.cert"
2424

2525
mkdir -p "${OUTSUBDIR}"
26+
# shellcheck disable=SC2046
2627
basename -a $(ls -1 "${SRCDIR}"/*-unsigned.exe) | while read UNSIGNED; do
2728
echo Signing "${UNSIGNED}"
2829
"${OSSLSIGNCODE}" sign -certs "${CERTFILE}" -t "${TIMESERVER}" -h sha256 -in "${SRCDIR}/${UNSIGNED}" -out "${WORKDIR}/${UNSIGNED}" "$@"

test/lint/lint-python-dead-code.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ fi
1515

1616
# --min-confidence 100 will only report code that is guaranteed to be unused within the analyzed files.
1717
# Any value below 100 introduces the risk of false positives, which would create an unacceptable maintenance burden.
18-
if ! vulture \
19-
--min-confidence 100 \
20-
$(git ls-files -- "*.py"); then
18+
mapfile -t FILES < <(git ls-files -- "*.py")
19+
if ! vulture --min-confidence 100 "${FILES[@]}"; then
2120
echo "Python dead code detection found some issues"
2221
exit 1
2322
fi

test/lint/lint-python.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ fi
9292

9393
EXIT_CODE=0
9494

95+
# shellcheck disable=SC2046
9596
if ! PYTHONWARNINGS="ignore" flake8 --ignore=B,C,E,F,I,N,W --select=$(IFS=","; echo "${enabled[*]}") $(
9697
if [[ $# == 0 ]]; then
9798
git ls-files "*.py"
@@ -102,7 +103,8 @@ if ! PYTHONWARNINGS="ignore" flake8 --ignore=B,C,E,F,I,N,W --select=$(IFS=","; e
102103
EXIT_CODE=1
103104
fi
104105

105-
if ! mypy --show-error-codes $(git ls-files "test/functional/*.py" "contrib/devtools/*.py"); then
106+
mapfile -t FILES < <(git ls-files "test/functional/*.py" "contrib/devtools/*.py")
107+
if ! mypy --show-error-codes "${FILES[@]}"; then
106108
EXIT_CODE=1
107109
fi
108110

test/lint/lint-shell.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export LC_ALL=C
1010

1111
# Disabled warnings:
1212
disabled=(
13-
SC2046 # Quote this to prevent word splitting.
1413
SC2162 # read without -r will mangle backslashes.
1514
)
1615

@@ -25,7 +24,8 @@ SHELLCHECK_CMD=(shellcheck --external-sources --check-sourced)
2524
EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")"
2625
# Check shellcheck directive used for sourced files
2726
mapfile -t SOURCED_FILES < <(git ls-files | xargs gawk '/^# shellcheck shell=/ {print FILENAME} {nextfile}')
28-
if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" "${SOURCED_FILES[@]}" $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|minisketch|univalue)/'); then
27+
mapfile -t FILES < <(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|minisketch|univalue)/')
28+
if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" "${SOURCED_FILES[@]}" "${FILES[@]}"; then
2929
EXIT_CODE=1
3030
fi
3131

test/lint/lint-spelling.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ if ! command -v codespell > /dev/null; then
1515
fi
1616

1717
IGNORE_WORDS_FILE=test/lint/lint-spelling.ignore-words.txt
18-
if ! codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=${IGNORE_WORDS_FILE} $(git ls-files -- ":(exclude)build-aux/m4/" ":(exclude)contrib/seeds/*.txt" ":(exclude)depends/" ":(exclude)doc/release-notes/" ":(exclude)src/leveldb/" ":(exclude)src/crc32c/" ":(exclude)src/qt/locale/" ":(exclude)src/qt/*.qrc" ":(exclude)src/secp256k1/" ":(exclude)src/minisketch/" ":(exclude)src/univalue/" ":(exclude)contrib/builder-keys/keys.txt" ":(exclude)contrib/guix/patches"); then
18+
mapfile -t FILES < <(git ls-files -- ":(exclude)build-aux/m4/" ":(exclude)contrib/seeds/*.txt" ":(exclude)depends/" ":(exclude)doc/release-notes/" ":(exclude)src/leveldb/" ":(exclude)src/crc32c/" ":(exclude)src/qt/locale/" ":(exclude)src/qt/*.qrc" ":(exclude)src/secp256k1/" ":(exclude)src/minisketch/" ":(exclude)src/univalue/" ":(exclude)contrib/builder-keys/keys.txt" ":(exclude)contrib/guix/patches")
19+
if ! codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=${IGNORE_WORDS_FILE} "${FILES[@]}"; then
1920
echo "^ Warning: codespell identified likely spelling errors. Any false positives? Add them to the list of ignored words in ${IGNORE_WORDS_FILE}"
2021
fi

0 commit comments

Comments
 (0)