Skip to content

Commit

Permalink
Ignore test tmp directories
Browse files Browse the repository at this point in the history
Attempting to iterate hard over some shell scripts can lead to
frustration when running static analysis. The problem occurs when you
either accidently add a tab to a shell file, or a trailing white space
character. Re-running the shellcheck then picks up the tmp.XXX
directories as you didn't delete them.

Deleting the directories shouldn't be mandatory as you may want to
analise them again in the future. Instead we should tell the checks to
ignore those tmp directories and move along.
  • Loading branch information
SimonRichardson committed Mar 30, 2020
1 parent c08ab6f commit 2912ff3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/suites/static_analysis/lint_shell.sh
@@ -1,5 +1,5 @@
run_shellcheck() {
OUT=$(shellcheck --shell sh tests/*.sh tests/includes/*.sh tests/suites/**/*.sh 2>&1 || true)
OUT=$(shellcheck --shell sh tests/main.sh tests/includes/*.sh tests/suites/**/*.sh 2>&1 || true)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
Expand All @@ -9,7 +9,8 @@ run_shellcheck() {
}

run_whitespace() {
OUT=$(grep -Pr '\t' tests/ | grep '\.sh:' || true)
# shellcheck disable=SC2063
OUT=$(grep -n -r --include "*.sh" "$(printf '\t')" tests/ | grep -oP "^.*:\d+" || true)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
Expand All @@ -20,7 +21,8 @@ run_whitespace() {
}

run_trailing_whitespace() {
OUT=$(grep -nr " $" tests/ | grep '\.sh:' || true)
# shellcheck disable=SC2063
OUT=$(grep -n -r --include "*.sh" " $" tests/ | grep -oP "^.*:\d+" || true)
if [ -n "${OUT}" ]; then
echo ""
echo "$(red 'Found some issues:')"
Expand Down

0 comments on commit 2912ff3

Please sign in to comment.