Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow Shellcheck to follow sourced files (closes #28) #36

Merged
merged 3 commits into from
Oct 28, 2021
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
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ scan_file(){
echo "###############################################"
echo " Scanning $file"
echo "###############################################"
shellcheck "$file_path" --severity="$severity_mode"
shellcheck -x "$file_path" --severity="$severity_mode"
local exit_code=$?
if [ $exit_code -eq 0 ] ; then
printf "%b" "Successfully scanned ${file_path} 🙌\n"
Expand Down
5 changes: 5 additions & 0 deletions test_data/test_dir/external_sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

if [[ -f ./src/tagging.sh ]]; then
. /src/tagging.sh
fi
10 changes: 10 additions & 0 deletions tests/unit_tests/scan_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ test_scan_unsuppoted_script(){
assertNotContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected2"
}

test_scan_external_sourced_file(){
local actual=$(scan_file ./test_data/test_dir/external_sources.sh)
local notExpected="SC1091: Not following"
local expected="Scanning external_sources.sh"

assertContains "Actual messages:$actual Did not contain the expected message.\n" "$actual" "$expected"
assertNotContains "Actual messages:$actual\n contains the unexpected message: '$notExpected'\n" "$actual" "$notExpected"

}

# scan_all() tests
test_scan_a_directory(){
local message1="Scanning all the shell scripts at ./test_data/script_type"
Expand Down