Merge pull request #10879 from ethereum/silence-remaining-shellcheck-warnings-and-remove-ignore-list

Silence remaining shellcheck warnings and remove ignore list
This commit is contained in:
Kamil Śliwak 2021-03-15 19:58:42 +01:00 committed by GitHub
commit 5376a3deb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 29 additions and 14 deletions

View File

@ -41,6 +41,7 @@ REPODIR="$(realpath "$(dirname "$0")/..")"
IFS=" " read -r -a BOOST_TEST_ARGS <<< "$BOOST_TEST_ARGS" IFS=" " read -r -a BOOST_TEST_ARGS <<< "$BOOST_TEST_ARGS"
IFS=" " read -r -a SOLTEST_FLAGS <<< "$SOLTEST_FLAGS" IFS=" " read -r -a SOLTEST_FLAGS <<< "$SOLTEST_FLAGS"
# shellcheck source=scripts/common.sh
source "${REPODIR}/scripts/common.sh" source "${REPODIR}/scripts/common.sh"
# Test result output directory (CircleCI is reading test results from here) # Test result output directory (CircleCI is reading test results from here)
mkdir -p test_results mkdir -p test_results

View File

@ -25,7 +25,7 @@ FAILED=0
UNCOMPILABLE=0 UNCOMPILABLE=0
TESTED=0 TESTED=0
if [ "$(ls | wc -l)" -ne 0 ]; then if [[ "$(find . -maxdepth 0 -type d -empty)" == "" ]]; then
echo "Test directory not empty. Skipping!" echo "Test directory not empty. Skipping!"
exit 1 exit 1
fi fi
@ -86,7 +86,8 @@ WORKINGDIR=$PWD
# boost_filesystem_bug specifically tests a local fix for a boost::filesystem # boost_filesystem_bug specifically tests a local fix for a boost::filesystem
# bug. Since the test involves a malformed path, there is no point in running # bug. Since the test involves a malformed path, there is no point in running
# AST tests on it. See https://github.com/boostorg/filesystem/issues/176 # AST tests on it. See https://github.com/boostorg/filesystem/issues/176
for solfile in $(find "$SYNTAXTESTS_DIR" "$ASTJSONTESTS_DIR" -name *.sol -and -not -name "boost_filesystem_bug.sol") # shellcheck disable=SC2044
for solfile in $(find "$SYNTAXTESTS_DIR" "$ASTJSONTESTS_DIR" -name "*.sol" -and -not -name "boost_filesystem_bug.sol")
do do
echo -n "." echo -n "."
# create a temporary sub-directory # create a temporary sub-directory

View File

@ -48,6 +48,7 @@ TMPDIR=$(mktemp -d)
cp "$REPO_ROOT/emscripten_build/libsolc/soljson.js" solc-js/ cp "$REPO_ROOT/emscripten_build/libsolc/soljson.js" solc-js/
cp "$REPO_ROOT/scripts/bytecodecompare/prepare_report.js" . cp "$REPO_ROOT/scripts/bytecodecompare/prepare_report.js" .
echo "Running the compiler..." echo "Running the compiler..."
# shellcheck disable=SC2035
./prepare_report.js *.sol > report.txt ./prepare_report.js *.sol > report.txt
echo "Finished running the compiler." echo "Finished running the compiler."
else else

View File

@ -4,16 +4,8 @@ set -eu
REPO_ROOT="$(dirname "$0")"/../.. REPO_ROOT="$(dirname "$0")"/../..
REPO_ROOT=$(realpath "${REPO_ROOT}") REPO_ROOT=$(realpath "${REPO_ROOT}")
IGNORE_FILENAME="ignore.txt"
IGNORE_FILE="${REPO_ROOT}/scripts/chk_shellscripts/${IGNORE_FILENAME}"
FOUND_FILES_TMP=$(mktemp)
IGNORE_FILES_TMP=$(mktemp)
trap 'rm -f ${FOUND_FILES_TMP} ; rm -f ${IGNORE_FILES_TMP}' EXIT
sort < "${IGNORE_FILE}" >"${IGNORE_FILES_TMP}"
cd "${REPO_ROOT}" cd "${REPO_ROOT}"
find . -type f -name "*.sh" | sort >"${FOUND_FILES_TMP}"
SHELLCHECK=${SHELLCHECK:-"$(command -v -- shellcheck)"} SHELLCHECK=${SHELLCHECK:-"$(command -v -- shellcheck)"}
if [ ! -f "${SHELLCHECK}" ]; then if [ ! -f "${SHELLCHECK}" ]; then
@ -21,7 +13,5 @@ if [ ! -f "${SHELLCHECK}" ]; then
exit 1 exit 1
fi fi
FILES=$(join -v2 "${IGNORE_FILES_TMP}" "${FOUND_FILES_TMP}") mapfile -t FILES < <(find . -type f -name "*.sh")
"${SHELLCHECK}" "${FILES[@]}"
# shellcheck disable=SC2086
"${SHELLCHECK}" ${FILES[*]}

View File

@ -205,6 +205,7 @@ sed -i -e "s/UNRELEASED/${distribution}/" -e s/urgency=medium/urgency=low/ ../*.
( (
cd .. cd ..
orig="${packagename}_${debversion}.orig.tar.gz" orig="${packagename}_${debversion}.orig.tar.gz"
# shellcheck disable=SC2012
orig_size=$(ls -l "$orig" | cut -d ' ' -f 5) orig_size=$(ls -l "$orig" | cut -d ' ' -f 5)
orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1) orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1) orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
@ -214,6 +215,7 @@ if wget --quiet -O $orig-tmp "$ppafilesurl/$orig"
then then
echo "[WARN] Original tarball found in Ubuntu archive, using it instead" echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
mv $orig-tmp $orig mv $orig-tmp $orig
# shellcheck disable=SC2012
new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5) new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5)
new_sha1=$(sha1sum $orig | cut -d ' ' -f 1) new_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
new_sha256=$(sha256sum $orig | cut -d ' ' -f 1) new_sha256=$(sha256sum $orig | cut -d ' ' -f 1)

View File

@ -29,7 +29,9 @@ set -e
REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd) REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build} SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
# shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh" source "${REPO_ROOT}/scripts/common.sh"
# shellcheck source=scripts/common_cmdline.sh
source "${REPO_ROOT}/scripts/common_cmdline.sh" source "${REPO_ROOT}/scripts/common_cmdline.sh"
developmentVersion=$("$REPO_ROOT/scripts/get_version.sh") developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
@ -38,7 +40,9 @@ function versionGreater()
{ {
v1=$1 v1=$1
v2=$2 v2=$2
# shellcheck disable=SC2206
ver1=( ${v1//./ } ) ver1=( ${v1//./ } )
# shellcheck disable=SC2206
ver2=( ${v2//./ } ) ver2=( ${v2//./ } )
if (( "${ver1[0]}" > "${ver2[0]}" )) if (( "${ver1[0]}" > "${ver2[0]}" ))

View File

@ -175,6 +175,7 @@ case $(uname -s) in
Debian*|Raspbian) Debian*|Raspbian)
#Debian #Debian
# shellcheck disable=SC1091
. /etc/os-release . /etc/os-release
install_z3="" install_z3=""
case $VERSION_ID in case $VERSION_ID in
@ -354,7 +355,10 @@ case $(uname -s) in
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
CentOS*) CentOS*)
echo "Attention: CentOS 7 is currently not supported!"; echo "Attention: CentOS 7 is currently not supported!";
# FIXME: read -p and [[ ]] are bash features but our shebang says we're using sh
# shellcheck disable=SC2039
read -p "This script will heavily modify your system in order to allow for compilation of Solidity. Are you sure? [Y/N]" -n 1 -r read -p "This script will heavily modify your system in order to allow for compilation of Solidity. Are you sure? [Y/N]" -n 1 -r
# shellcheck disable=SC2039
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
# Make Sure we have the EPEL repos # Make Sure we have the EPEL repos
sudo yum -y install epel-release sudo yum -y install epel-release

View File

@ -265,6 +265,7 @@ fi
( (
cd .. cd ..
orig="${packagename}_${debversion}.orig.tar.gz" orig="${packagename}_${debversion}.orig.tar.gz"
# shellcheck disable=SC2012
orig_size=$(ls -l "$orig" | cut -d ' ' -f 5) orig_size=$(ls -l "$orig" | cut -d ' ' -f 5)
orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)
@ -274,6 +275,7 @@ if wget --quiet -O "$orig-tmp" "$ppafilesurl/$orig"
then then
echo "[WARN] Original tarball found in Ubuntu archive, using it instead" echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
mv "$orig-tmp" "$orig" mv "$orig-tmp" "$orig"
# shellcheck disable=SC2012
new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5) new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5)
new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)

View File

@ -32,6 +32,7 @@ REPO_ROOT="$(dirname "$0")/.."
SOLIDITY_BUILD_DIR="${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}" SOLIDITY_BUILD_DIR="${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}"
IFS=" " read -r -a SMT_FLAGS <<< "$SMT_FLAGS" IFS=" " read -r -a SMT_FLAGS <<< "$SMT_FLAGS"
# shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh" source "${REPO_ROOT}/scripts/common.sh"
WORKDIR=$(mktemp -d) WORKDIR=$(mktemp -d)

View File

@ -190,6 +190,7 @@ echo "Extract bytecode comparison scripts from v0.6.1..."
cd /root/project cd /root/project
git checkout v0.6.1 --quiet git checkout v0.6.1 --quiet
cp scripts/bytecodecompare/storebytecode.sh /tmp cp scripts/bytecodecompare/storebytecode.sh /tmp
# shellcheck disable=SC2016
sed -i -e 's/rm -rf "\$TMPDIR"/cp "\$TMPDIR"\/report.txt \/tmp\/report.txt ; rm -rf "\$TMPDIR"/' /tmp/storebytecode.sh sed -i -e 's/rm -rf "\$TMPDIR"/cp "\$TMPDIR"\/report.txt \/tmp\/report.txt ; rm -rf "\$TMPDIR"/' /tmp/storebytecode.sh
sed -i -e 's/REPO_ROOT=.*/REPO_ROOT=\/src/' /tmp/storebytecode.sh sed -i -e 's/REPO_ROOT=.*/REPO_ROOT=\/src/' /tmp/storebytecode.sh
export SOLC_EMSCRIPTEN="On" export SOLC_EMSCRIPTEN="On"

View File

@ -32,7 +32,9 @@ set -e
REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd) REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build} SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
# shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh" source "${REPO_ROOT}/scripts/common.sh"
# shellcheck source=scripts/common_cmdline.sh
source "${REPO_ROOT}/scripts/common_cmdline.sh" source "${REPO_ROOT}/scripts/common_cmdline.sh"
(( $# <= 1 )) || { printError "Too many arguments"; exit 1; } (( $# <= 1 )) || { printError "Too many arguments"; exit 1; }
@ -124,6 +126,7 @@ function test_solc_behaviour()
local stdout_path; stdout_path=$(mktemp) local stdout_path; stdout_path=$(mktemp)
local stderr_path; stderr_path=$(mktemp) local stderr_path; stderr_path=$(mktemp)
# shellcheck disable=SC2064
trap "rm -f $stdout_path $stderr_path" EXIT trap "rm -f $stdout_path $stderr_path" EXIT
if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi
@ -144,10 +147,13 @@ function test_solc_behaviour()
# Remove bytecode (but not linker references). # Remove bytecode (but not linker references).
sed -i.bak -E -e 's/(\"object\":\")[0-9a-f]+([^"]*\")/\1<BYTECODE REMOVED>\2/g' "$stdout_path" sed -i.bak -E -e 's/(\"object\":\")[0-9a-f]+([^"]*\")/\1<BYTECODE REMOVED>\2/g' "$stdout_path"
# shellcheck disable=SC2016
sed -i.bak -E -e 's/(\"object\":\"[^"]+\$__)[0-9a-f]+(\")/\1<BYTECODE REMOVED>\2/g' "$stdout_path" sed -i.bak -E -e 's/(\"object\":\"[^"]+\$__)[0-9a-f]+(\")/\1<BYTECODE REMOVED>\2/g' "$stdout_path"
# shellcheck disable=SC2016
sed -i.bak -E -e 's/([0-9a-f]{34}\$__)[0-9a-f]+(__\$[0-9a-f]{17})/\1<BYTECODE REMOVED>\2/g' "$stdout_path" sed -i.bak -E -e 's/([0-9a-f]{34}\$__)[0-9a-f]+(__\$[0-9a-f]{17})/\1<BYTECODE REMOVED>\2/g' "$stdout_path"
# Replace escaped newlines by actual newlines for readability # Replace escaped newlines by actual newlines for readability
# shellcheck disable=SC1003
sed -i.bak -E -e 's/\\n/\'$'\n/g' "$stdout_path" sed -i.bak -E -e 's/\\n/\'$'\n/g' "$stdout_path"
rm "$stdout_path.bak" rm "$stdout_path.bak"
else else
@ -164,7 +170,9 @@ function test_solc_behaviour()
# 64697066735822 = hex encoding of 0x64 'i' 'p' 'f' 's' 0x58 0x22 # 64697066735822 = hex encoding of 0x64 'i' 'p' 'f' 's' 0x58 0x22
# 64736f6c63 = hex encoding of 0x64 's' 'o' 'l' 'c' # 64736f6c63 = hex encoding of 0x64 's' 'o' 'l' 'c'
sed -i.bak -E -e 's/[0-9a-f]*64697066735822[0-9a-f]+64736f6c63[0-9a-f]+/<BYTECODE REMOVED>/g' "$stdout_path" sed -i.bak -E -e 's/[0-9a-f]*64697066735822[0-9a-f]+64736f6c63[0-9a-f]+/<BYTECODE REMOVED>/g' "$stdout_path"
# shellcheck disable=SC2016
sed -i.bak -E -e 's/([0-9a-f]{17}\$__)[0-9a-f]+(__\$[0-9a-f]{17})/\1<BYTECODE REMOVED>\2/g' "$stdout_path" sed -i.bak -E -e 's/([0-9a-f]{17}\$__)[0-9a-f]+(__\$[0-9a-f]{17})/\1<BYTECODE REMOVED>\2/g' "$stdout_path"
# shellcheck disable=SC2016
sed -i.bak -E -e 's/[0-9a-f]+((__\$[0-9a-f]{34}\$__)*<BYTECODE REMOVED>)/<BYTECODE REMOVED>\1/g' "$stdout_path" sed -i.bak -E -e 's/[0-9a-f]+((__\$[0-9a-f]{34}\$__)*<BYTECODE REMOVED>)/<BYTECODE REMOVED>\1/g' "$stdout_path"
# Remove trailing empty lines. Needs a line break to make OSX sed happy. # Remove trailing empty lines. Needs a line break to make OSX sed happy.