mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-21 21:50:59 -05:00
Fix ShellCheck issues with new code base
This commit is contained in:
parent
0101612f7a
commit
889179e0bf
4 changed files with 13 additions and 24 deletions
2
.vscode/testlinter.sh
vendored
2
.vscode/testlinter.sh
vendored
|
@ -22,5 +22,5 @@ fi
|
|||
#########################
|
||||
export RUN_LOCAL=true
|
||||
|
||||
# shellcheck disable=SC1091,SC1090
|
||||
# shellcheck source=../lib/linter.sh
|
||||
source "$PWD"/lib/linter.sh
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
@ -56,8 +55,7 @@ function BuildFileList()
|
|||
#################################################
|
||||
# Get the Array of files changed in the commits #
|
||||
#################################################
|
||||
# shellcheck disable=SC2207
|
||||
RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "$DEFAULT_BRANCH..$GITHUB_SHA" --diff-filter=d 2>&1))
|
||||
mapfile -t RAW_FILE_ARRAY < <(git -C "$GITHUB_WORKSPACE" diff --name-only "$DEFAULT_BRANCH..$GITHUB_SHA" --diff-filter=d 2>&1)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
|
@ -413,6 +411,8 @@ function BuildFileList()
|
|||
fi
|
||||
done
|
||||
|
||||
echo $READ_ONLY_CHANGE_FLAG > /dev/null 2>&1 || true # Workaround SC2034
|
||||
|
||||
#########################################
|
||||
# Need to switch back to branch of code #
|
||||
#########################################
|
||||
|
|
|
@ -9,8 +9,11 @@
|
|||
#########################
|
||||
# Source Function Files #
|
||||
#########################
|
||||
# shellcheck source=../lib/buildFileList.sh
|
||||
source /action/lib/buildFileList.sh # Source the function script(s)
|
||||
# shellcheck source=../lib/validation.sh
|
||||
source /action/lib/validation.sh # Source the function script(s)
|
||||
# shellcheck source=../lib/worker.sh
|
||||
source /action/lib/worker.sh # Source the function script(s)
|
||||
|
||||
###########
|
||||
|
@ -146,15 +149,10 @@ DEFAULT_IFS="$IFS" # Get the Default IFS for updating
|
|||
###############################################################
|
||||
# Default Vars that are called in Subs and need to be ignored #
|
||||
###############################################################
|
||||
# shellcheck disable=SC2034
|
||||
DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors
|
||||
# shellcheck disable=SC2034
|
||||
RAW_FILE_ARRAY=() # Array of all files that were changed
|
||||
# shellcheck disable=SC2034
|
||||
READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md
|
||||
# shellcheck disable=SC2034
|
||||
TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore
|
||||
# shellcheck disable=SC2034
|
||||
DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory
|
||||
|
||||
##########################
|
||||
|
@ -1103,8 +1101,7 @@ if [ "$VALIDATE_OPENAPI" == "true" ]; then
|
|||
###############################################################################
|
||||
IFS=$'\n'
|
||||
|
||||
# shellcheck disable=SC2207
|
||||
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1))
|
||||
mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE" -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
||||
for FILE in "${LIST_FILES[@]}"
|
||||
do
|
||||
if DetectOpenAPIFile "$FILE"; then
|
||||
|
|
|
@ -38,7 +38,6 @@ function LintCodebase()
|
|||
#######################################
|
||||
# Validate we have jsonlint installed #
|
||||
#######################################
|
||||
# shellcheck disable=SC2230
|
||||
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
||||
|
||||
#######################
|
||||
|
@ -91,8 +90,7 @@ function LintCodebase()
|
|||
#################################
|
||||
# Get list of all files to lint #
|
||||
#################################
|
||||
# shellcheck disable=SC2207,SC2086
|
||||
LIST_FILES=($(cd "$GITHUB_WORKSPACE" || exit; find . -type f -regex "$FILE_EXTENSIONS" 2>&1))
|
||||
mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE" -type f -regex "$FILE_EXTENSIONS" 2>&1)
|
||||
|
||||
###########################
|
||||
# Set IFS back to default #
|
||||
|
@ -229,7 +227,6 @@ function TestCodebase()
|
|||
#####################################
|
||||
# Validate we have linter installed #
|
||||
#####################################
|
||||
# shellcheck disable=SC2230
|
||||
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
||||
|
||||
#######################
|
||||
|
@ -263,8 +260,7 @@ function TestCodebase()
|
|||
#################################
|
||||
# Get list of all files to lint #
|
||||
#################################
|
||||
# shellcheck disable=SC2207,SC2086,SC2010
|
||||
LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; ls ansible/ | grep ".yml" 2>&1))
|
||||
mapfile -t LIST_FILES < <(ls "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/ansible/*.yml" 2>&1)
|
||||
else
|
||||
###############################################################################
|
||||
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
||||
|
@ -274,8 +270,7 @@ function TestCodebase()
|
|||
#################################
|
||||
# Get list of all files to lint #
|
||||
#################################
|
||||
# shellcheck disable=SC2207,SC2086
|
||||
LIST_FILES=($(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; find "$INDVIDUAL_TEST_FOLDER" -type f -regex "$FILE_EXTENSIONS" ! -path "*./ansible*" 2>&1))
|
||||
mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$INDVIDUAL_TEST_FOLDER" -type f -regex "$FILE_EXTENSIONS" ! -path "*./ansible*" 2>&1)
|
||||
|
||||
###########################
|
||||
# Set IFS back to default #
|
||||
|
@ -505,7 +500,6 @@ function LintAnsibleFiles()
|
|||
###########################################
|
||||
# Validate we have ansible-lint installed #
|
||||
###########################################
|
||||
# shellcheck disable=SC2230
|
||||
VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1)
|
||||
|
||||
#######################
|
||||
|
@ -551,14 +545,12 @@ function LintAnsibleFiles()
|
|||
if [ "$VALIDATE_ALL_CODEBASE" == "false" ]; then
|
||||
# We need to only check the ansible playbooks that have updates
|
||||
#LIST_FILES=("${ANSIBLE_ARRAY[@]}")
|
||||
# shellcheck disable=SC2164,SC2010,SC2207
|
||||
LIST_FILES=($(cd "$ANSIBLE_DIRECTORY"; ls | grep ".yml" 2>&1))
|
||||
mapfile -t LIST_FILES < <(ls "$ANSIBLE_DIRECTORY/*.yml" 2>&1)
|
||||
else
|
||||
#################################
|
||||
# Get list of all files to lint #
|
||||
#################################
|
||||
# shellcheck disable=SC2164,SC2010,SC2207
|
||||
LIST_FILES=($(cd "$ANSIBLE_DIRECTORY"; ls | grep ".yml" 2>&1))
|
||||
mapfile -t LIST_FILES < <(ls "$ANSIBLE_DIRECTORY/*.yml" 2>&1)
|
||||
fi
|
||||
|
||||
###############################################################
|
||||
|
|
Loading…
Reference in a new issue