From 39d7c1a397b776bd9a85448655606e0cc2eaab99 Mon Sep 17 00:00:00 2001 From: Harvey Lynden Date: Fri, 2 Aug 2024 10:50:10 +0200 Subject: [PATCH] Path Configuration / Profile Check-lint will now check for config file avocado_static_checks.conf one directory above as the submodule is placed into the root of the directory. If the file is not present it will return back to the old method. Reference: https://github.com/avocado-framework/avocado-static-checks/issues/5 Signed-off-by: --- check-lint | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/check-lint b/check-lint index 2bf0bec..7b2dcaa 100755 --- a/check-lint +++ b/check-lint @@ -1,9 +1,26 @@ #!/bin/sh -e -TOOL_CMD=pylint -PATH=$(basename $0)/utils:$PATH +CONFIG_FILE="../.avocado_static_checks.conf" +DEFAULT_CONFIG_PATH="default_configs/pylintrc" CONFIG_PATH="$(dirname $0)/default_configs/pylintrc" + +get_config() { + local file_path="$1" + if [ -f "$CONFIG_FILE" ]; then + while IFS=':' read -r pattern config; do + if [[ "$file_path" == $pattern* ]]; then + echo "$config" + return + fi + done < "$CONFIG_FILE" + fi + echo "$DEFAULT_CONFIG_PATH" +} + FILES=$(git ls-files '*.py') -echo "** Running $TOOL_CMD (using config from $CONFIG_PATH)..." -python3 -m pylint --rcfile=$CONFIG_PATH $FILES +for file in $FILES; do + CONFIG_PATH=$(get_config "$file") + echo "** Running pylint (using config from $CONFIG_PATH) on $file..." + python3 -m pylint --rcfile="$CONFIG_PATH" "$file" +done \ No newline at end of file