foundry-scripts
foundry-scripts copied to clipboard
ci(gh): shell checker
sh-checker report
To get the full details, please check in the job output.
shellcheck errors
'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:
----------
In cast/checksum-address.sh line 10:
if [ "$ETH_FROM" != "$(seth --to-checksum-address "$ETH_FROM")" ]; then
^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ "$ETH_FROM" != "$(seth --to-checksum-address "$ETH_FROM")" ]]; then
In forge/minify-output.sh line 8:
if [ -f "$arg" ]; then
^-----------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ -f "$arg" ]]; then
In forge/minify-output.sh line 9:
if [ -n "$path" ]; then
^------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ -n "$path" ]]; then
In gas-snapshot/src/reporting/coverage-snapshot.sh line 3:
01_gas_report=$(cat .gas-snapshot)
^-- SC2282 (error): Variable names can't start with numbers, so this is interpreted as a command.
^------------------^ SC2046 (warning): Quote this to prevent word splitting.
In scripts/clone-and-checkout.sh line 10:
if [ -d "$cloneDirName" ]; then
^--------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ -d "$cloneDirName" ]]; then
In scripts/clone-and-checkout.sh line 11:
(cd "$cloneDirName" && [ -z "$(git status --porcelain)" ] && git checkout "$2") || (echo Unclean "$cloneDirName" && exit 1)
^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
(cd "$cloneDirName" && [[ -z "$(git status --porcelain)" ]] && git checkout "$2") || (echo Unclean "$cloneDirName" && exit 1)
In scripts/common.sh line 25:
if [ $(($(tput colors 2>/dev/null))) -ge 8 ]; then
^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ $(($(tput colors 2>/dev/null))) -ge 8 ]]; then
In scripts/common.sh line 44:
if [ "$ETH_FROM" != "$(cast --to-checksum-address "$ETH_FROM")" ]; then
^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ "$ETH_FROM" != "$(cast --to-checksum-address "$ETH_FROM")" ]]; then
In scripts/common.sh line 60:
ARGS=${@:2}
^----^ SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
In scripts/common.sh line 63:
CONTRACT_PATH=$(find ./src -name $NAME.sol)
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
CONTRACT_PATH=$(find ./src -name "$NAME".sol)
In scripts/common.sh line 97:
result=$(cat "$ADDRESSES_FILE" | jq -r ". + {\"$1\": \"$2\"}")
^---------------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
In scripts/common.sh line 103:
ARGS=${@:2}
^----^ SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
In scripts/common.sh line 128:
echo " \
^-- SC2028 (info): echo may not expand escape sequences. Use printf.
In scripts/common.sh line 141:
echo " \
^-- SC2028 (info): echo may not expand escape sequences. Use printf.
In scripts/common.sh line 151:
ARGS=${@:2}
^----^ SC2124 (warning): Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
In scripts/common.sh line 157:
length=$(echo "$BYTECODE" | wc -m)
^----------------------^ SC2000 (style): See if you can use ${#variable} instead.
In scripts/common.sh line 158:
echo $(($length / 2))
^-----^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
In scripts/contract-size.sh line 5:
. $(dirname $0)/common.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
^---------------------^ SC1091 (info): Not following: ./common.sh was not specified as input (see shellcheck -x).
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
. $(dirname "$0")/common.sh
In scripts/contract-size.sh line 9:
echo '"$contract" env variable is not set. Set it to the name of the contract you want to estimate size for.'
^-- SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
In scripts/contract-size.sh line 15:
contract_size=$(contract_size ${contract})
^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
contract_size=$(contract_size "${contract}")
In scripts/contract-size.sh line 18:
echo "$((24576 - ${contract_size})) bytes left to reach the smart contract size limit of 24576 bytes."
^--------------^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
In scripts/dapptools/verify.sh line 142:
while [ $count -lt 5 ]; do
^--------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
while [[ $count -lt 5 ]]; do
In scripts/deploy.sh line 6:
. $(dirname $0)/common.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
^---------------------^ SC1091 (info): Not following: ./common.sh was not specified as input (see shellcheck -x).
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
. $(dirname "$0")/common.sh
In scripts/deploy.sh line 9:
. $(dirname $0)/helper-config.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
^----------------------------^ SC1091 (info): Not following: ./helper-config.sh was not specified as input (see shellcheck -x).
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
. $(dirname "$0")/helper-config.sh
In scripts/deploy.sh line 13:
: ${CONTRACT:=Greeter}
^------------------^ SC2223 (info): This default assignment may cause DoS due to globbing. Quote it.
In scripts/deploy.sh line 14:
echo "Deploying $CONTRACT to $NETWORK with arguments: $arguments"
^--------^ SC2154 (warning): arguments is referenced but not assigned.
In scripts/deploy.sh line 15:
Addr=$(deploy $CONTRACT $arguments)
^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
Addr=$(deploy $CONTRACT "$arguments")
In scripts/deploy.sh line 16:
log "$CONTRACT deployed at:" $Addr
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
log "$CONTRACT deployed at:" "$Addr"
In scripts/env-check.sh line 4:
cd "$(git rev-parse --show-toplevel)"
^-- SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
Did you mean:
cd "$(git rev-parse --show-toplevel)" || exit
In scripts/estimate-gas.sh line 5:
. $(dirname $0)/common.sh
^-----------^ SC2046 (warning): Quote this to prevent word splitting.
^---------------------^ SC1091 (info): Not following: ./common.sh was not specified as input (see shellcheck -x).
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
. $(dirname "$0")/common.sh
In scripts/estimate-gas.sh line 9:
echo '"$contract" env variable is not set. Set it to the name of the contract you want to estimate gas cost for.'
^-- SC2016 (info): Expressions don't expand in single quotes, use double quotes for that.
In scripts/estimate-gas.sh line 16:
estimate_gas $contract
^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
estimate_gas "$contract"
In scripts/git/add-module line 3:
[ -z "$1" -o $(echo "$1" | tr '/' '\n' | wc -l) != 2 ] &&
^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
^-- SC2166 (warning): Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
^-- SC2046 (warning): Quote this to prevent word splitting.
In scripts/git/add-module line 11:
[ -n "$2" ] && DEST="$2"
^---------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
[[ -n "$2" ]] && DEST="$2"
In scripts/git/git-ssh line 3:
git remote set-url origin $(git remote show origin | grep "Fetch URL" | sed 's/ *Fetch URL: //' | sed 's/https:\/\/github.com\//[email protected]:/')
^-- SC2046 (warning): Quote this to prevent word splitting.
In scripts/helper-config.sh line 11:
if [ "$NETWORK" = "rinkeby" ]; then
^------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ "$NETWORK" = "rinkeby" ]]; then
In scripts/helper-config.sh line 15:
elif [ "$NETWORK" = "mainnet" ]; then
^------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
elif [[ "$NETWORK" = "mainnet" ]]; then
In scripts/helper-config.sh line 21:
if [ "$CONTRACT" = "Greeter" ]; then
^-------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ "$CONTRACT" = "Greeter" ]]; then
In scripts/hevm.sh line 3:
hevm dapp-test --rpc="${ETH_RPC_URL}" --json-file=out/dapp.sol.json --dapp-root=. --verbose 2 --match "test_gas"
^--^ SC2264 (error): This function unconditionally re-invokes itself. Missing 'command'?
Did you mean:
command hevm dapp-test --rpc="${ETH_RPC_URL}" --json-file=out/dapp.sol.json --dapp-root=. --verbose 2 --match "test_gas"
In scripts/mod/json-fix.sh line 3:
forge $cmd | tail -n +2 | tee $outputFile
^--^ SC2154 (warning): cmd is referenced but not assigned.
^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
^---------^ SC2154 (warning): outputFile is referenced but not assigned.
^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
forge "$cmd" | tail -n +2 | tee "$outputFile"
In scripts/remove-color-output.sh line 3:
forge $cmd | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | tee $outputFile
^--^ SC2154 (warning): cmd is referenced but not assigned.
^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
^---------^ SC2154 (warning): outputFile is referenced but not assigned.
^---------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
forge "$cmd" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" | tee "$outputFile"
In scripts/utils.sh line 25:
echo "[Error] $@"
^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.
In scripts/utils.sh line 30:
if [ $? -ne 0 ]; then
^----------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
Did you mean:
if [[ $? -ne 0 ]]; then
In scripts/utils.sh line 32:
echo "[Error] $@"
^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.
In scripts/utils.sh line 38:
cat /dev/urandom | env LC_CTYPE=C tr -dc $1 | head -c $2
^----------^ SC2002 (style): Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
cat /dev/urandom | env LC_CTYPE=C tr -dc "$1" | head -c "$2"
In scripts/utils.sh line 44:
echo $(random [:alpha:] 1)$(random [:alnum:] 15)
^-------------------^ SC2046 (warning): Quote this to prevent word splitting.
^-------^ SC2101 (warning): Named class needs outer [], e.g. [[:digit:]].
^--------------------^ SC2046 (warning): Quote this to prevent word splitting.
^-------^ SC2101 (warning): Named class needs outer [], e.g. [[:digit:]].
In scripts/utils.sh line 50:
if [ "${logging_lvl}" == "debug" ]; then echo "[Debug] $@"; fi
^-----------------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.
Did you mean:
if [[ "${logging_lvl}" == "debug" ]]; then echo "[Debug] $@"; fi
In scripts/utils.sh line 54:
if [[ "${logging_lvl}" =~ (debug|info) ]]; then echo "[Info] $@"; fi
^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.
In scripts/utils.sh line 58:
if [[ "${logging_lvl}" =~ (debug|info|error) ]]; then echo && echo "[Error] $@"; fi
^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.
In scripts/utils.sh line 62:
if [ -z ${logging_lvl} ]; then
^-------------------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [[ -z "${logging_lvl}" ]]; then
In scripts/utils.sh line 79:
echo "[Running '$@']"
^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.
In scripts/utils.sh line 80:
$@
^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.
In scripts/utils.sh line 81:
echo "['$@' finished in $SECONDS seconds]"
^-- SC2145 (error): Argument mixes string and array. Use * or separate argument.
In src/init.sh line 10:
log_file="foundry_script_log-`date +'%Y-%m-%d_%H-%M-%S'`.txt"
^-------------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
log_file="foundry_script_log-$(date +'%Y-%m-%d_%H-%M-%S').txt"
In src/init.sh line 14:
if [[ "$(basename $0)" = "install.sh" ]]; then
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
if [[ "$(basename "$0")" = "install.sh" ]]; then
In src/init.sh line 15:
cd "$(dirname $0)/install/"
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
cd "$(dirname "$0")/install/"
In src/init.sh line 17:
cd "$(dirname $0)" # assume we're a test script or some such
^-- SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
cd "$(dirname "$0")" # assume we're a test script or some such
In src/init.sh line 29:
t=$(mktemp) && export -p > "$t" && set -a && . $_ENV && set +a && . "$t" && rm "$t" && unset t
^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
Did you mean:
t=$(mktemp) && export -p > "$t" && set -a && . "$_ENV" && set +a && . "$t" && rm "$t" && unset t
For more information:
https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. ...
https://www.shellcheck.net/wiki/SC2264 -- This function unconditionally re-...
----------
You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
# shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.
shfmt errors
'shfmt -s' returned error 1 finding the following formatting issues:
----------
--- scripts/common.sh.orig
+++ scripts/common.sh
@@ -155,5 +155,5 @@
# get the bytecode from the compiled file
BYTECODE=0x$(jq -r "$PATTERN.evm.bytecode.object" out/dapp.sol.json)
length=$(echo "$BYTECODE" | wc -m)
- echo $(($length / 2))
+ echo $((length / 2))
}
--- scripts/contract-size.sh.orig
+++ scripts/contract-size.sh
@@ -15,4 +15,4 @@
contract_size=$(contract_size ${contract})
echo "Contract Name: ${contract}"
echo "Contract Size: ${contract_size} bytes"
-echo "$((24576 - ${contract_size})) bytes left to reach the smart contract size limit of 24576 bytes."
+echo "$((24576 - contract_size)) bytes left to reach the smart contract size limit of 24576 bytes."
--- scripts/dapptools/verify.sh.orig
+++ scripts/dapptools/verify.sh
@@ -114,7 +114,7 @@
fi
fi
-if [[ "$optimized" = "true" ]]; then
+if [[ $optimized == "true" ]]; then
optimized=1
else
optimized=0
@@ -153,16 +153,16 @@
message=$(jshon <<<"$response" -e message -u)
count=$((count + 1))
- [[ $status = 1 ]] && break
+ [[ $status == 1 ]] && break
done
-[[ $status = 0 && $message = "Contract source code already verified" ]] && {
+[[ $status == 0 && $message == "Contract source code already verified" ]] && {
echo >&2 "Contract source code already verified."
echo >&2 "Go to $ETHERSCAN_URL/$2#code"
exit 0
}
-[[ $status = 0 ]] && {
+[[ $status == 0 ]] && {
echo >&2 "There was an error verifying this contract."
echo >&2 "Response: $message"
echo >&2 "Details: $guid"
@@ -178,13 +178,13 @@
status=$(jshon <<<"$response" -e status -u)
result=$(jshon <<<"$response" -e result -u)
-[[ $status = 1 ]] && {
+[[ $status == 1 ]] && {
echo >&2 "$result"
echo >&2 "Go to $ETHERSCAN_URL/$2#code"
exit 0
}
-[[ $status = 0 ]] && {
+[[ $status == 0 ]] && {
echo >&2 "Failure"
echo >&2 "$result"
exit 1
--- scripts/utils.sh.orig
+++ scripts/utils.sh
@@ -51,11 +51,11 @@
}
log_info() {
- if [[ "${logging_lvl}" =~ (debug|info) ]]; then echo "[Info] $@"; fi
+ if [[ ${logging_lvl} =~ (debug|info) ]]; then echo "[Info] $@"; fi
}
log_error() {
- if [[ "${logging_lvl}" =~ (debug|info|error) ]]; then echo && echo "[Error] $@"; fi
+ if [[ ${logging_lvl} =~ (debug|info|error) ]]; then echo && echo "[Error] $@"; fi
}
log_set_logging_lvl() {
@@ -66,7 +66,7 @@
}
logging_lvl_validate() {
- if [[ "${logging_lvl}" =~ (debug|info|error) ]]; then
+ if [[ ${logging_lvl} =~ (debug|info|error) ]]; then
log_debug " [Validation Passed] logging_lvl = '${logging_lvl}'"
else
exit_with_error " [Validation Failed] Unsupported logging level '${logging_lvl}'. Supported loggin levels are 'debug|info|error'."
--- src/init.sh.orig
+++ src/init.sh
@@ -7,14 +7,14 @@
umask 002
## @note https://unix.stackexchange.com/a/145654/108960
-log_file="foundry_script_log-`date +'%Y-%m-%d_%H-%M-%S'`.txt"
+log_file="foundry_script_log-$(date +'%Y-%m-%d_%H-%M-%S').txt"
exec &> >(tee -a "$log_file")
# Work from /install/ for install.sh, project root otherwise
-if [[ "$(basename $0)" = "install.sh" ]]; then
+if [[ "$(basename $0)" == "install.sh" ]]; then
cd "$(dirname $0)/install/"
else
- cd "$(dirname $0)" # assume we're a test script or some such
+ cd "$(dirname $0)" # assume we're a test script or some such
fi
## Allow `.env` overrides using the `.env.custom` file
@@ -26,4 +26,4 @@
## Read .env for default values
## @see https://stackoverflow.com/a/59831605/90297
-t=$(mktemp) && export -p > "$t" && set -a && . $_ENV && set +a && . "$t" && rm "$t" && unset t
+t=$(mktemp) && export -p >"$t" && set -a && . $_ENV && set +a && . "$t" && rm "$t" && unset t
----------
You can reformat the above files to meet shfmt's requirements by typing:
shfmt -s -w filename