From fe0ff569ea6c353f88609c0f5f9b6fa80ff74f15 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 7 Nov 2021 14:37:56 +0200 Subject: test: Enable SC2046 shellcheck rule --- ci/lint/04_install.sh | 4 ++-- ci/lint/06_script.sh | 3 ++- ci/test/04_install.sh | 2 +- ci/test/wrap-qemu.sh | 2 +- ci/test/wrap-valgrind.sh | 2 +- contrib/windeploy/detached-sig-create.sh | 1 + test/lint/lint-python-dead-code.sh | 5 ++--- test/lint/lint-python.sh | 4 +++- test/lint/lint-shell.sh | 4 ++-- test/lint/lint-spelling.sh | 3 ++- 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ci/lint/04_install.sh b/ci/lint/04_install.sh index 991234a436..251ac76cad 100755 --- a/ci/lint/04_install.sh +++ b/ci/lint/04_install.sh @@ -8,8 +8,8 @@ export LC_ALL=C ${CI_RETRY_EXE} apt-get update ${CI_RETRY_EXE} apt-get install -y clang-format-9 python3-pip curl git gawk jq -update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-9 ) 100 -update-alternatives --install /usr/bin/clang-format-diff clang-format-diff $(which clang-format-diff-9) 100 +update-alternatives --install /usr/bin/clang-format clang-format "$(which clang-format-9 )" 100 +update-alternatives --install /usr/bin/clang-format-diff clang-format-diff "$(which clang-format-diff-9)" 100 ${CI_RETRY_EXE} pip3 install codespell==2.0.0 ${CI_RETRY_EXE} pip3 install flake8==3.8.3 diff --git a/ci/lint/06_script.sh b/ci/lint/06_script.sh index bcb50308b5..16bc00285f 100755 --- a/ci/lint/06_script.sh +++ b/ci/lint/06_script.sh @@ -31,7 +31,8 @@ if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; t # sanity checking only a few (10) commits seems sufficient and cheap. git log HEAD~10 -1 --format='%H' > ./contrib/verify-commits/trusted-sha512-root-commit git log HEAD~10 -1 --format='%H' > ./contrib/verify-commits/trusted-git-root - ${CI_RETRY_EXE} gpg --keyserver hkps://keys.openpgp.org --recv-keys $( "$b" diff --git a/ci/test/wrap-valgrind.sh b/ci/test/wrap-valgrind.sh index d3cdf77ded..38cc5e0ca7 100755 --- a/ci/test/wrap-valgrind.sh +++ b/ci/test/wrap-valgrind.sh @@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8 for b_name in "${BASE_OUTDIR}/bin"/*; do # shellcheck disable=SC2044 - for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name $(basename "$b_name")); do + for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do echo "Wrap $b ..." mv "$b" "${b}_orig" echo '#!/usr/bin/env bash' > "$b" diff --git a/contrib/windeploy/detached-sig-create.sh b/contrib/windeploy/detached-sig-create.sh index 29802e622e..fb5cb4a4d9 100755 --- a/contrib/windeploy/detached-sig-create.sh +++ b/contrib/windeploy/detached-sig-create.sh @@ -23,6 +23,7 @@ TIMESERVER=http://timestamp.comodoca.com CERTFILE="win-codesign.cert" mkdir -p "${OUTSUBDIR}" +# shellcheck disable=SC2046 basename -a $(ls -1 "${SRCDIR}"/*-unsigned.exe) | while read UNSIGNED; do echo Signing "${UNSIGNED}" "${OSSLSIGNCODE}" sign -certs "${CERTFILE}" -t "${TIMESERVER}" -h sha256 -in "${SRCDIR}/${UNSIGNED}" -out "${WORKDIR}/${UNSIGNED}" "$@" diff --git a/test/lint/lint-python-dead-code.sh b/test/lint/lint-python-dead-code.sh index c3b6ff3c98..247bfb310a 100755 --- a/test/lint/lint-python-dead-code.sh +++ b/test/lint/lint-python-dead-code.sh @@ -15,9 +15,8 @@ fi # --min-confidence 100 will only report code that is guaranteed to be unused within the analyzed files. # Any value below 100 introduces the risk of false positives, which would create an unacceptable maintenance burden. -if ! vulture \ - --min-confidence 100 \ - $(git ls-files -- "*.py"); then +mapfile -t FILES < <(git ls-files -- "*.py") +if ! vulture --min-confidence 100 "${FILES[@]}"; then echo "Python dead code detection found some issues" exit 1 fi diff --git a/test/lint/lint-python.sh b/test/lint/lint-python.sh index 3d22407fd1..96b34d715e 100755 --- a/test/lint/lint-python.sh +++ b/test/lint/lint-python.sh @@ -92,6 +92,7 @@ fi EXIT_CODE=0 +# shellcheck disable=SC2046 if ! PYTHONWARNINGS="ignore" flake8 --ignore=B,C,E,F,I,N,W --select=$(IFS=","; echo "${enabled[*]}") $( if [[ $# == 0 ]]; then git ls-files "*.py" @@ -102,7 +103,8 @@ if ! PYTHONWARNINGS="ignore" flake8 --ignore=B,C,E,F,I,N,W --select=$(IFS=","; e EXIT_CODE=1 fi -if ! mypy --show-error-codes $(git ls-files "test/functional/*.py" "contrib/devtools/*.py"); then +mapfile -t FILES < <(git ls-files "test/functional/*.py" "contrib/devtools/*.py") +if ! mypy --show-error-codes "${FILES[@]}"; then EXIT_CODE=1 fi diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 1a12df6591..d697dfcbea 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -10,7 +10,6 @@ export LC_ALL=C # Disabled warnings: disabled=( - SC2046 # Quote this to prevent word splitting. SC2162 # read without -r will mangle backslashes. ) @@ -25,7 +24,8 @@ SHELLCHECK_CMD=(shellcheck --external-sources --check-sourced) EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")" # Check shellcheck directive used for sourced files mapfile -t SOURCED_FILES < <(git ls-files | xargs gawk '/^# shellcheck shell=/ {print FILENAME} {nextfile}') -if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" "${SOURCED_FILES[@]}" $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|minisketch|univalue)/'); then +mapfile -t FILES < <(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|minisketch|univalue)/') +if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" "${SOURCED_FILES[@]}" "${FILES[@]}"; then EXIT_CODE=1 fi diff --git a/test/lint/lint-spelling.sh b/test/lint/lint-spelling.sh index 8eefa8f2ce..c98003de8d 100755 --- a/test/lint/lint-spelling.sh +++ b/test/lint/lint-spelling.sh @@ -15,6 +15,7 @@ if ! command -v codespell > /dev/null; then fi IGNORE_WORDS_FILE=test/lint/lint-spelling.ignore-words.txt -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 +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") +if ! codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=${IGNORE_WORDS_FILE} "${FILES[@]}"; then echo "^ Warning: codespell identified likely spelling errors. Any false positives? Add them to the list of ignored words in ${IGNORE_WORDS_FILE}" fi -- cgit v1.2.3