diff --git a/scripts/shellcheck.bash b/scripts/shellcheck.bash index cfc18669..7db77a0f 100755 --- a/scripts/shellcheck.bash +++ b/scripts/shellcheck.bash @@ -7,6 +7,10 @@ # - 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 @@ -23,7 +27,7 @@ file="$1" if [[ "${file/*./}" == "bats" ]]; then sed 's/^@.*/func() {/' "$file" | sed 's/^load.*/source test\/functional\/testlib.bash/' | - shellcheck -s bash -x -e SC1008 /dev/stdin + shellcheck -s bash -x -e SC1008,SC2119 /dev/stdin else - shellcheck -x "$file" + shellcheck -x "$file" -e SC2119 fi diff --git a/test/functional/testlib.bash b/test/functional/testlib.bash index a7481b7a..d9103115 100644 --- a/test/functional/testlib.bash +++ b/test/functional/testlib.bash @@ -2004,9 +2004,7 @@ destroy_test_environment() { # swupd_function debug_msg "The --force option was used" fi - # shellcheck disable=SC2119 destroy_web_server - # shellcheck disable=SC2119 destroy_trusted_cacert # if the test environment doesn't exist warn the user but don't terminate script @@ -2162,7 +2160,6 @@ create_config_file() { # swupd_function if [ -e "$SWUPD_CONFIG_FILE" ]; then debug_msg "A config file already existed in that location, deleting it..." - # shellcheck disable=SC2119 destroy_config_file fi @@ -4369,7 +4366,6 @@ setup() { if [ "$DEBUG_TEST" = true ] || [ "$SHOW_TARGET" = true ]; then print "\nTarget system before the test:" - # shellcheck disable=SC2119 show_target fi if [ "$TEST_ENV_ONLY" = true ]; then @@ -4403,7 +4399,6 @@ teardown() { if [ "$DEBUG_TEST" = true ] || [ "$SHOW_TARGET" = true ]; then print "\nTarget system after the test:" - # shellcheck disable=SC2119 show_target fi diff --git a/test/functional/update/update-attr-change.bats b/test/functional/update/update-attr-change.bats index 0129a59a..28058d3b 100755 --- a/test/functional/update/update-attr-change.bats +++ b/test/functional/update/update-attr-change.bats @@ -119,7 +119,6 @@ test_setup() { run stat --printf "%a" "$TARGETDIR"/dir_sticky [ "$output" -eq "1755" ] - # shellcheck disable=SC2119 show_target } diff --git a/test/functional/update/update-boot-manager.bats b/test/functional/update/update-boot-manager.bats index 3aa5db80..c60353ab 100755 --- a/test/functional/update/update-boot-manager.bats +++ b/test/functional/update/update-boot-manager.bats @@ -59,7 +59,6 @@ test_setup() { EOM ) assert_is_output "$expected_output" - # shellcheck disable=SC2119 show_target } diff --git a/test/functional/update/update-type-changes-dir-to-file.bats b/test/functional/update/update-type-changes-dir-to-file.bats index 2b3b09cf..ef16173c 100755 --- a/test/functional/update/update-type-changes-dir-to-file.bats +++ b/test/functional/update/update-type-changes-dir-to-file.bats @@ -76,7 +76,6 @@ test_setup() { assert_dir_not_exists "$TARGETDIR"/dir1 assert_file_exists "$TARGETDIR"/dir1 assert_file_exists "$TARGETDIR"/common_file - # shellcheck disable=SC2119 show_target } diff --git a/test/functional/update/update-type-changes-file-to-symlink.bats b/test/functional/update/update-type-changes-file-to-symlink.bats index d1a48b3d..092aacef 100755 --- a/test/functional/update/update-type-changes-file-to-symlink.bats +++ b/test/functional/update/update-type-changes-file-to-symlink.bats @@ -80,7 +80,6 @@ test_setup() { assert_file_exists "$TARGETDIR"/dir1/dir2/file2 assert_file_exists "$TARGETDIR"/file3 assert_file_exists "$TARGETDIR"/file4 - # shellcheck disable=SC2119 show_target }