Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence remaining shellcheck warnings and remove ignore list #10879

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/soltest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ REPODIR="$(realpath "$(dirname "$0")/..")"
IFS=" " read -r -a BOOST_TEST_ARGS <<< "$BOOST_TEST_ARGS"
IFS=" " read -r -a SOLTEST_FLAGS <<< "$SOLTEST_FLAGS"

# shellcheck source=scripts/common.sh
source "${REPODIR}/scripts/common.sh"
# Test result output directory (CircleCI is reading test results from here)
mkdir -p test_results
Expand Down
5 changes: 3 additions & 2 deletions scripts/ASTImportTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FAILED=0
UNCOMPILABLE=0
TESTED=0

if [ "$(ls | wc -l)" -ne 0 ]; then
if [[ "$(find . -maxdepth 0 -type d -empty)" == "" ]]; then
echo "Test directory not empty. Skipping!"
exit 1
fi
Expand Down Expand Up @@ -86,7 +86,8 @@ WORKINGDIR=$PWD
# 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
# 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
echo -n "."
# create a temporary sub-directory
Expand Down
1 change: 1 addition & 0 deletions scripts/bytecodecompare/storebytecode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ TMPDIR=$(mktemp -d)
cp "$REPO_ROOT/emscripten_build/libsolc/soljson.js" solc-js/
cp "$REPO_ROOT/scripts/bytecodecompare/prepare_report.js" .
echo "Running the compiler..."
# shellcheck disable=SC2035
./prepare_report.js *.sol > report.txt
echo "Finished running the compiler."
else
Expand Down
14 changes: 2 additions & 12 deletions scripts/chk_shellscripts/chk_shellscripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@ set -eu

REPO_ROOT="$(dirname "$0")"/../..
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}"
find . -type f -name "*.sh" | sort >"${FOUND_FILES_TMP}"

SHELLCHECK=${SHELLCHECK:-"$(command -v -- shellcheck)"}
if [ ! -f "${SHELLCHECK}" ]; then
echo "error: shellcheck '${SHELLCHECK}' not found."
exit 1
fi

FILES=$(join -v2 "${IGNORE_FILES_TMP}" "${FOUND_FILES_TMP}")

# shellcheck disable=SC2086
"${SHELLCHECK}" ${FILES[*]}
mapfile -t FILES < <(find . -type f -name "*.sh")
"${SHELLCHECK}" "${FILES[@]}"
2 changes: 2 additions & 0 deletions scripts/deps-ppa/static_z3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ sed -i -e "s/UNRELEASED/${distribution}/" -e s/urgency=medium/urgency=low/ ../*.
(
cd ..
orig="${packagename}_${debversion}.orig.tar.gz"
# shellcheck disable=SC2012
orig_size=$(ls -l "$orig" | cut -d ' ' -f 5)
orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
Expand All @@ -214,6 +215,7 @@ if wget --quiet -O $orig-tmp "$ppafilesurl/$orig"
then
echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
mv $orig-tmp $orig
# shellcheck disable=SC2012
new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5)
new_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
new_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
Expand Down
4 changes: 4 additions & 0 deletions scripts/docs_version_pragma_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ set -e

REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
# shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh"
# shellcheck source=scripts/common_cmdline.sh
source "${REPO_ROOT}/scripts/common_cmdline.sh"

developmentVersion=$("$REPO_ROOT/scripts/get_version.sh")
Expand All @@ -38,7 +40,9 @@ function versionGreater()
{
v1=$1
v2=$2
# shellcheck disable=SC2206
ver1=( ${v1//./ } )
# shellcheck disable=SC2206
ver2=( ${v2//./ } )

if (( "${ver1[0]}" > "${ver2[0]}" ))
Expand Down
4 changes: 4 additions & 0 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ case $(uname -s) in

Debian*|Raspbian)
#Debian
# shellcheck disable=SC1091
. /etc/os-release
install_z3=""
case $VERSION_ID in
Expand Down Expand Up @@ -354,7 +355,10 @@ case $(uname -s) in
#------------------------------------------------------------------------------
CentOS*)
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
# shellcheck disable=SC2039
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Make Sure we have the EPEL repos
sudo yum -y install epel-release
Expand Down
2 changes: 2 additions & 0 deletions scripts/release_ppa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ fi
(
cd ..
orig="${packagename}_${debversion}.orig.tar.gz"
# shellcheck disable=SC2012
orig_size=$(ls -l "$orig" | cut -d ' ' -f 5)
orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)
Expand All @@ -274,6 +275,7 @@ if wget --quiet -O "$orig-tmp" "$ppafilesurl/$orig"
then
echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
mv "$orig-tmp" "$orig"
# shellcheck disable=SC2012
new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5)
new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)
Expand Down
1 change: 1 addition & 0 deletions scripts/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ REPO_ROOT="$(dirname "$0")/.."
SOLIDITY_BUILD_DIR="${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}"
IFS=" " read -r -a SMT_FLAGS <<< "$SMT_FLAGS"

# shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh"

WORKDIR=$(mktemp -d)
Expand Down
1 change: 1 addition & 0 deletions scripts/wasm-rebuild/docker-scripts/rebuild_tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ echo "Extract bytecode comparison scripts from v0.6.1..."
cd /root/project
git checkout v0.6.1 --quiet
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/REPO_ROOT=.*/REPO_ROOT=\/src/' /tmp/storebytecode.sh
export SOLC_EMSCRIPTEN="On"
Expand Down
8 changes: 8 additions & 0 deletions test/cmdlineTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ set -e

REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
SOLIDITY_BUILD_DIR=${SOLIDITY_BUILD_DIR:-${REPO_ROOT}/build}
# shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh"
# shellcheck source=scripts/common_cmdline.sh
source "${REPO_ROOT}/scripts/common_cmdline.sh"

(( $# <= 1 )) || { printError "Too many arguments"; exit 1; }
Expand Down Expand Up @@ -124,6 +126,7 @@ function test_solc_behaviour()
local stdout_path; stdout_path=$(mktemp)
local stderr_path; stderr_path=$(mktemp)

# shellcheck disable=SC2064
trap "rm -f $stdout_path $stderr_path" EXIT

if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi
Expand All @@ -144,10 +147,13 @@ function test_solc_behaviour()

# Remove bytecode (but not linker references).
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"
# 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"

# Replace escaped newlines by actual newlines for readability
# shellcheck disable=SC1003
sed -i.bak -E -e 's/\\n/\'$'\n/g' "$stdout_path"
rm "$stdout_path.bak"
else
Expand All @@ -164,7 +170,9 @@ function test_solc_behaviour()
# 64697066735822 = hex encoding of 0x64 'i' 'p' 'f' 's' 0x58 0x22
# 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"
# 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"
# shellcheck disable=SC2016
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.
Expand Down