mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-08-28 18:15:42 +00:00
ce0943982a
Ignoring error SC2119 because they are false positives and I don't see cases where that would return anything useful for us. Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
34 lines
972 B
Bash
Executable File
34 lines
972 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Wrapper to run shellcheck with configurations used by swupd project and
|
|
# doing necessary changes to validate bats files
|
|
|
|
# Ignored checks:
|
|
# - SC1008: This shebang was unrecognized.
|
|
# We need to skip this check when processing bats tests because the shebang
|
|
# is not a shell.
|
|
# - SC2119: Use foo "$@" if function's $1 should mean script's $1.
|
|
# We need to skip this check because in many ocassions we use functions
|
|
# that are not expecting arguments, but still shellcheck will detect this
|
|
# as error because the show_help which is called from all functions uses $@
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
cat <<-EOM
|
|
Invalid number of arguments
|
|
|
|
Usage:
|
|
./scripts/shellcheck.bash <shellscript_file>
|
|
EOM
|
|
exit 1
|
|
fi
|
|
|
|
file="$1"
|
|
|
|
if [[ "${file/*./}" == "bats" ]]; then
|
|
sed 's/^@.*/func() {/' "$file" |
|
|
sed 's/^load.*/source test\/functional\/testlib.bash/' |
|
|
shellcheck -s bash -x -e SC1008,SC2119 /dev/stdin
|
|
else
|
|
shellcheck -x "$file" -e SC2119
|
|
fi
|