From 5d0d37988e6c7275b525b144e4ae9a94c55bfb26 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Fri, 16 Feb 2024 18:31:06 +0100 Subject: [PATCH] scripts: checkcode: Guess the source directory if no argument is provided I always forgot to do that... Signed-off-by: Jan Kiszka --- scripts/checkcode.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/checkcode.sh b/scripts/checkcode.sh index 19495810..d37f6a91 100755 --- a/scripts/checkcode.sh +++ b/scripts/checkcode.sh @@ -3,20 +3,21 @@ ERROR=0 if [ $# != 1 ]; then - echo "Error: Please provide a path as the argument to this script!" - exit 1 + SRCDIR=$(dirname "$0")/.. +else + SRCDIR=$1 fi echo "Checking with pycodestyle" -pycodestyle --ignore=W503,W606 "$1"/*.py "$1"/*/*.py || ERROR=$((ERROR + 1)) +pycodestyle --ignore=W503,W606 "$SRCDIR"/*.py "$SRCDIR"/*/*.py || ERROR=$((ERROR + 1)) echo "Checking with flake8" -flake8 "$1" || ERROR=$((ERROR + 2)) +flake8 "$SRCDIR" || ERROR=$((ERROR + 2)) echo "Checking with doc8" -doc8 "$1"/docs --ignore-path "$1"/docs/_build || ERROR=$((ERROR + 4)) +doc8 "$SRCDIR"/docs --ignore-path "$SRCDIR"/docs/_build || ERROR=$((ERROR + 4)) echo "Checking with shellcheck" -shellcheck "$1"/kas-container "$1"/scripts/release.sh "$1"/scripts/checkcode.sh "$1"/container-entrypoint || ERROR=$((ERROR + 8)) +shellcheck "$SRCDIR"/kas-container "$SRCDIR"/scripts/release.sh "$SRCDIR"/scripts/checkcode.sh "$SRCDIR"/container-entrypoint || ERROR=$((ERROR + 8)) exit $ERROR