diff --git a/.automation/cleanup-docker.sh b/.automation/cleanup-docker.sh index ab0bb546..889c4d65 100755 --- a/.automation/cleanup-docker.sh +++ b/.automation/cleanup-docker.sh @@ -51,25 +51,25 @@ ValidateInput() { ############################ # Validate GITHUB_WORKSPACE # ############################ - if [ -z "$GITHUB_WORKSPACE" ]; then + if [ -z "${GITHUB_WORKSPACE}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}" exit 1 else - echo "Successfully found:[GITHUB_WORKSPACE], value:[$GITHUB_WORKSPACE]" + echo "Successfully found:[GITHUB_WORKSPACE], value:[${GITHUB_WORKSPACE}]" fi ####################### # Validate IMAGE_REPO # ####################### - if [ -z "$IMAGE_REPO" ]; then + if [ -z "${IMAGE_REPO}" ]; then # No repo was pulled echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}" exit 1 - elif [[ $IMAGE_REPO == "github/super-linter" ]]; then + elif [[ ${IMAGE_REPO} == "github/super-linter" ]]; then # Found our main repo - echo "Successfully found:[IMAGE_REPO], value:[$IMAGE_REPO]" + echo "Successfully found:[IMAGE_REPO], value:[${IMAGE_REPO}]" else # This is a fork and we cant pull vars or any info echo -e "${NC}${F[Y]}WARN!${NC} No image to cleanup as this is a forked branch, and not being built with current automation!${NC}" @@ -79,31 +79,31 @@ ValidateInput() { ########################## # Validate IMAGE_VERSION # ########################## - if [ -z "$IMAGE_VERSION" ]; then + if [ -z "${IMAGE_VERSION}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_VERSION]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_VERSION]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_VERSION}]${NC}" exit 1 else - echo "Successfully found:[IMAGE_VERSION], value:[$IMAGE_VERSION]" + echo "Successfully found:[IMAGE_VERSION], value:[${IMAGE_VERSION}]" fi ############################ # Validate DOCKER_USERNAME # ############################ - if [ -z "$DOCKER_USERNAME" ]; then + if [ -z "${DOCKER_USERNAME}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}" exit 1 else - echo "Successfully found:[DOCKER_USERNAME], value:[$DOCKER_USERNAME]" + echo "Successfully found:[DOCKER_USERNAME], value:[${DOCKER_USERNAME}]" fi ############################ # Validate DOCKER_PASSWORD # ############################ - if [ -z "$DOCKER_PASSWORD" ]; then + if [ -z "${DOCKER_PASSWORD}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}" exit 1 else echo "Successfully found:[DOCKER_PASSWORD], value:[********]" @@ -112,11 +112,11 @@ ValidateInput() { ################################################## # Check if we need to get the name of the branch # ################################################## - if [[ $IMAGE_VERSION != "latest" ]]; then + if [[ ${IMAGE_VERSION} != "latest" ]]; then ################################## # Remove non alpha-numeric chars # ################################## - IMAGE_VERSION=$(echo "$IMAGE_VERSION" | tr -cd '[:alnum:]') + IMAGE_VERSION=$(echo "${IMAGE_VERSION}" | tr -cd '[:alnum:]') else ############################################# # Image is 'latest' and we will not destroy # @@ -142,7 +142,7 @@ LoginToDocker() { ###################### # Login to DockerHub # ###################### - LOGIN_CMD=$(docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD" 2>&1) + LOGIN_CMD=$(docker login --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}" 2>&1) ####################### # Load the error code # @@ -152,10 +152,10 @@ LoginToDocker() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to DockerHub!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}" exit 1 else # SUCCESS @@ -170,7 +170,7 @@ RemoveImage() { ################ echo "" echo "----------------------------------------------" - echo "Removing the DockerFile image:[$IMAGE_REPO:$IMAGE_VERSION]" + echo "Removing the DockerFile image:[${IMAGE_REPO}:${IMAGE_VERSION}]" echo "----------------------------------------------" echo "" @@ -180,7 +180,7 @@ RemoveImage() { TOKEN=$(curl -s -k \ -H "Content-Type: application/json" \ -X POST \ - -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" \ + -d "{\"username\": \"${DOCKER_USERNAME}\", \"password\": \"${DOCKER_PASSWORD}\"}" \ "https://hub.docker.com/v2/users/login/" | jq -r .token 2>&1) ####################### @@ -191,10 +191,10 @@ RemoveImage() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain token from DockerHub!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$TOKEN]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${TOKEN}]${NC}" exit 1 else # SUCCESS @@ -204,9 +204,9 @@ RemoveImage() { ################################# # Remove the tag from DockerHub # ################################# - REMOVE_CMD=$(curl "https://hub.docker.com/v2/repositories/$IMAGE_REPO/tags/$IMAGE_VERSION/" \ + REMOVE_CMD=$(curl "https://hub.docker.com/v2/repositories/${IMAGE_REPO}/tags/${IMAGE_VERSION}/" \ -X DELETE \ - -H "Authorization: JWT $TOKEN" 2>&1) + -H "Authorization: JWT ${TOKEN}" 2>&1) ####################### # Load the ERROR_CODE # @@ -216,14 +216,14 @@ RemoveImage() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to remove tag from DockerHub!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REMOVE_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REMOVE_CMD}]${NC}" exit 1 else # SUCCESS - echo "Successfully [removed] Docker image tag:[$IMAGE_VERSION] from DockerHub!" + echo "Successfully [removed] Docker image tag:[${IMAGE_VERSION}] from DockerHub!" fi } ################################################################################ diff --git a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh index 0fe1e1e0..2d4b0eec 100644 --- a/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh +++ b/.automation/test/ansible/ghe-initialize/templates/ghe-config-apply.sh @@ -26,23 +26,23 @@ CheckGHEPid() ################################## # Check to prevent infinite loop # ################################## - if [ $PID_CHECK -gt $PID_CHECK_LIMIT ]; then + if [ ${PID_CHECK} -gt ${PID_CHECK_LIMIT} ]; then # Over the limit, move on - echo "We have checked the pid $PID_CHECK times, moving on..." + echo "We have checked the pid ${PID_CHECK} times, moving on..." else ################################################ # Check to see if the PID is alive and running # ################################################ - if [ ! -f "$GHE_CONFIG_PID" ]; then + if [ ! -f "${GHE_CONFIG_PID}" ]; then # File not found - echo "We're good to move forward, no .pid file found at:[$GHE_CONFIG_PID]" + echo "We're good to move forward, no .pid file found at:[${GHE_CONFIG_PID}]" else # Found the pid running, need to sleep - echo "Current PID found, sleeping $SLEEP_SECONDS seconds before next check..." + echo "Current PID found, sleeping ${SLEEP_SECONDS} seconds before next check..." ################ # Sleep it off # ################ - SLEEP_CMD=$(sleep $SLEEP_SECONDS 2>&1) + SLEEP_CMD=$(sleep ${SLEEP_SECONDS} 2>&1) ####################### # Load the error code # @@ -52,9 +52,9 @@ CheckGHEPid() ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -80,14 +80,14 @@ CheckGHEProcess() ################################## # Check to prevent infinite loop # ################################## - if [ $PROCESS_CHECK -gt $PROCESS_CHECK_LIMIT ]; then + if [ ${PROCESS_CHECK} -gt ${PROCESS_CHECK_LIMIT} ]; then # Over the limit, move on - echo "We have checked the process $PROCESS_CHECK times, moving on..." + echo "We have checked the process ${PROCESS_CHECK} times, moving on..." else #################################################### # Check to see if the process is alive and running # #################################################### - CHECK_PROCESS_CMD=$(pgrep -f "$GHE_APPLY_COMMAND" 2>&1) + CHECK_PROCESS_CMD=$(pgrep -f "${GHE_APPLY_COMMAND}" 2>&1) ####################### # Load the error code # @@ -97,16 +97,16 @@ CheckGHEProcess() ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # No process running on the system - echo "Were good to move forward, no process like:[$GHE_APPLY_COMMAND] running currently on the system" + echo "Were good to move forward, no process like:[${GHE_APPLY_COMMAND}] running currently on the system" else # Found the process running, need to sleep - echo "Current process alive:[$CHECK_PROCESS_CMD], sleeping $SLEEP_SECONDS seconds before next check..." + echo "Current process alive:[${CHECK_PROCESS_CMD}], sleeping ${SLEEP_SECONDS} seconds before next check..." ################ # Sleep it off # ################ - SLEEP_CMD=$(sleep $SLEEP_SECONDS 2>&1) + SLEEP_CMD=$(sleep ${SLEEP_SECONDS} 2>&1) ####################### # Load the error code # @@ -116,9 +116,9 @@ CheckGHEProcess() ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to sleep!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SLEEP_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SLEEP_CMD}]${NC}" echo "Will try to call apply as last effort..." #################################### # Call config apply as last effort # @@ -144,7 +144,7 @@ RunConfigApply() ########## # Header # ########## - echo "Running $GHE_APPLY_COMMAND to the server..." + echo "Running ${GHE_APPLY_COMMAND} to the server..." ############################################## # Run the command to apply changes to server # @@ -159,14 +159,14 @@ RunConfigApply() ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Errors echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to run config apply command!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$APPLY_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${APPLY_CMD}]${NC}" exit 1 else # Success - echo -e "${NC}${F[B]}Successfully ran ${F[C]}$GHE_APPLY_COMMAND${NC}" + echo -e "${NC}${F[B]}Successfully ran ${F[C]}${GHE_APPLY_COMMAND}${NC}" fi } ################################################################################ diff --git a/.automation/test/shell/shell_good_1.sh b/.automation/test/shell/shell_good_1.sh index 9a1f5bc5..ee5435e5 100644 --- a/.automation/test/shell/shell_good_1.sh +++ b/.automation/test/shell/shell_good_1.sh @@ -7,11 +7,11 @@ HELLO_WORLD=$(echo "Hello World" | cut -f1 -d' ' 2>&1) ERROR_CODE=$? # Check the shell -if [ $ERROR_CODE -ne 0 ]; then +if [ ${ERROR_CODE} -ne 0 ]; then echo "We did it!" exit 0 else echo "We done goofed it..." - echo "$HELLO_WORLD" + echo "${HELLO_WORLD}" exit 1 fi diff --git a/.automation/upload-docker.sh b/.automation/upload-docker.sh index 321b7f1d..42ea1c65 100755 --- a/.automation/upload-docker.sh +++ b/.automation/upload-docker.sh @@ -37,7 +37,7 @@ UPDATE_MAJOR_TAG=0 # Flag to deploy the major tag version as Header() { echo "" echo "-------------------------------------------------------" - echo "---- GitHub Actions Upload image to [$REGISTRY] ----" + echo "---- GitHub Actions Upload image to [${REGISTRY}] ----" echo "-------------------------------------------------------" echo "" } @@ -57,46 +57,46 @@ ValidateInput() { ############################# # Validate GITHUB_WORKSPACE # ############################# - if [ -z "$GITHUB_WORKSPACE" ]; then + if [ -z "${GITHUB_WORKSPACE}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[$GITHUB_WORKSPACE]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" fi ##################### # Validate REGISTRY # ##################### - if [ -z "$REGISTRY" ]; then + if [ -z "${REGISTRY}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [REGISTRY]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$REGISTRY]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${REGISTRY}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[$REGISTRY]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[REGISTRY]${F[B]}, value:${F[W]}[${REGISTRY}]${NC}" fi ##################################################### # See if we need values for GitHub package Registry # ##################################################### - if [[ $REGISTRY == "GPR" ]]; then + if [[ ${REGISTRY} == "GPR" ]]; then ######################### # Validate GPR_USERNAME # ######################### - if [ -z "$GPR_USERNAME" ]; then + if [ -z "${GPR_USERNAME}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_USERNAME]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_USERNAME]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_USERNAME}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[$GPR_USERNAME]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_USERNAME]${F[B]}, value:${F[W]}[${GPR_USERNAME}]${NC}" fi ###################### # Validate GPR_TOKEN # ###################### - if [ -z "$GPR_TOKEN" ]; then + if [ -z "${GPR_TOKEN}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GPR_TOKEN]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GPR_TOKEN]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GPR_TOKEN}]${NC}" exit 1 else echo -e "${NC}${F[B]}Successfully found:${F[W]}[GPR_TOKEN]${F[B]}, value:${F[W]}[********]${NC}" @@ -104,24 +104,24 @@ ValidateInput() { ######################################## # See if we need values for Ducker hub # ######################################## - elif [[ $REGISTRY == "Docker" ]]; then + elif [[ ${REGISTRY} == "Docker" ]]; then ############################ # Validate DOCKER_USERNAME # ############################ - if [ -z "$DOCKER_USERNAME" ]; then + if [ -z "${DOCKER_USERNAME}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_USERNAME]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_USERNAME]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_USERNAME}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[$DOCKER_USERNAME]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_USERNAME]${F[B]}, value:${F[W]}[${DOCKER_USERNAME}]${NC}" fi ############################ # Validate DOCKER_PASSWORD # ############################ - if [ -z "$DOCKER_PASSWORD" ]; then + if [ -z "${DOCKER_PASSWORD}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKER_PASSWORD]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKER_PASSWORD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKER_PASSWORD}]${NC}" exit 1 else echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKER_PASSWORD]${F[B]}, value:${F[B]}[********]${NC}" @@ -131,39 +131,39 @@ ValidateInput() { ########################################### else echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find a valid registry!${NC}" - echo "Registry:[$REGISTRY]" + echo "Registry:[${REGISTRY}]" exit 1 fi ####################### # Validate IMAGE_REPO # ####################### - if [ -z "$IMAGE_REPO" ]; then + if [ -z "${IMAGE_REPO}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [IMAGE_REPO]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$IMAGE_REPO]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${IMAGE_REPO}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[$IMAGE_REPO]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_REPO]${F[B]}, value:${F[W]}[${IMAGE_REPO}]${NC}" ############################################### # Need to see if GPR registry and update name # ############################################### - if [[ $REGISTRY == "GPR" ]]; then - NAME="docker.pkg.github.com/$IMAGE_REPO/super-linter" - IMAGE_REPO="$NAME" - echo "Updated [IMAGE_REPO] to:[$IMAGE_REPO] for GPR" + if [[ ${REGISTRY} == "GPR" ]]; then + NAME="docker.pkg.github.com/${IMAGE_REPO}/super-linter" + IMAGE_REPO="${NAME}" + echo "Updated [IMAGE_REPO] to:[${IMAGE_REPO}] for GPR" fi fi ########################## # Validate IMAGE_VERSION # ########################## - if [ -z "$IMAGE_VERSION" ]; then + if [ -z "${IMAGE_VERSION}" ]; then echo -e "${NC}${F[Y]}WARN!${NC} Failed to get [IMAGE_VERSION]!${NC}" echo "Pulling from Branch Name..." ############################## # Get the name of the branch # ############################## - BRANCH_NAME=$(git -C "$GITHUB_WORKSPACE" branch --contains "$GITHUB_SHA" | awk '{print $2}' 2>&1) + BRANCH_NAME=$(git -C "${GITHUB_WORKSPACE}" branch --contains "${GITHUB_SHA}" | awk '{print ${2}}' 2>&1) ####################### # Load the error code # @@ -173,24 +173,24 @@ ValidateInput() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get branch name!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$BRANCH_NAME]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${BRANCH_NAME}]${NC}" exit 1 fi ################################## # Remove non alpha-numeric chars # ################################## - BRANCH_NAME=$(echo "$BRANCH_NAME" | tr -cd '[:alnum:]') + BRANCH_NAME=$(echo "${BRANCH_NAME}" | tr -cd '[:alnum:]') ############################################ # Set the IMAGE_VERSION to the BRANCH_NAME # ############################################ - IMAGE_VERSION="$BRANCH_NAME" - echo "Tag:[$IMAGE_VERSION]" + IMAGE_VERSION="${BRANCH_NAME}" + echo "Tag:[${IMAGE_VERSION}]" else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[$IMAGE_VERSION]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[IMAGE_VERSION]${F[B]}, value:${F[W]}[${IMAGE_VERSION}]${NC}" fi ################################## @@ -201,31 +201,31 @@ ValidateInput() { ###################################################################### # Check if this is a latest to a versioned release at create new tag # ###################################################################### - if [[ $IMAGE_VERSION =~ $REGEX ]]; then + if [[ ${IMAGE_VERSION} =~ ${REGEX} ]]; then # Need to get the major version, and set flag to update ##################### # Set the major tag # ##################### - MAJOR_TAG=$(echo "$IMAGE_VERSION" | cut -d '.' -f1) + MAJOR_TAG=$(echo "${IMAGE_VERSION}" | cut -d '.' -f1) ################################### # Set flag for updating major tag # ################################### UPDATE_MAJOR_TAG=1 - echo "- Also deploying a major tag of:[$MAJOR_TAG]" + echo "- Also deploying a major tag of:[${MAJOR_TAG}]" fi ############################ # Validate DOCKERFILE_PATH # ############################ - if [ -z "$DOCKERFILE_PATH" ]; then + if [ -z "${DOCKERFILE_PATH}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [DOCKERFILE_PATH]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$DOCKERFILE_PATH]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${DOCKERFILE_PATH}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[$DOCKERFILE_PATH]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[DOCKERFILE_PATH]${F[B]}, value:${F[W]}[${DOCKERFILE_PATH}]${NC}" fi } ################################################################################ @@ -234,24 +234,24 @@ Authenticate() { ################ # Pull in Vars # ################ - USERNAME="$1" # Name to auth with - PASSWORD="$2" # Password to auth with - URL="$3" # Url to auth towards - NAME="$4" # name of the service + USERNAME="${1}" # Name to auth with + PASSWORD="${2}" # Password to auth with + URL="${3}" # Url to auth towards + NAME="${4}" # name of the service ################ # Print header # ################ echo "" echo "----------------------------------------------" - echo "Login to $NAME..." + echo "Login to ${NAME}..." echo "----------------------------------------------" echo "" ################### # Auth to service # ################### - LOGIN_CMD=$(docker login "$URL" --username "$USERNAME" --password "$PASSWORD" 2>&1) + LOGIN_CMD=$(docker login "${URL}" --username "${USERNAME}" --password "${PASSWORD}" 2>&1) ####################### # Load the error code # @@ -261,14 +261,14 @@ Authenticate() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to $NAME!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LOGIN_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to authenticate to ${NAME}!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LOGIN_CMD}]${NC}" exit 1 else # SUCCESS - echo -e "${NC}${F[B]}Successfully authenticated to ${F[C]}$NAME${F[B]}!${NC}" + echo -e "${NC}${F[B]}Successfully authenticated to ${F[C]}${NAME}${F[B]}!${NC}" fi } ################################################################################ @@ -286,9 +286,9 @@ BuildImage() { ################################ # Validate the DOCKERFILE_PATH # ################################ - if [ ! -f "$DOCKERFILE_PATH" ]; then + if [ ! -f "${DOCKERFILE_PATH}" ]; then # No file found - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[$DOCKERFILE_PATH]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to find Dockerfile at:[${DOCKERFILE_PATH}]${NC}" echo "Please make sure you give full path!" echo "Example:[/configs/Dockerfile] or [Dockerfile] if at root directory" exit 1 @@ -297,7 +297,7 @@ BuildImage() { ################### # Build the image # ################### - docker build --no-cache -t "$IMAGE_REPO:$IMAGE_VERSION" -f "$DOCKERFILE_PATH" . 2>&1 + docker build --no-cache -t "${IMAGE_REPO}:${IMAGE_VERSION}" -f "${DOCKERFILE_PATH}" . 2>&1 ####################### # Load the error code # @@ -307,7 +307,7 @@ BuildImage() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [build] Dockerfile!${NC}" exit 1 @@ -319,9 +319,9 @@ BuildImage() { ######################################################## # Need to see if we need to tag a major update as well # ######################################################## - if [ $UPDATE_MAJOR_TAG -eq 1 ]; then + if [ ${UPDATE_MAJOR_TAG} -eq 1 ]; then # Tag the image with the major tag as well - docker build -t "$IMAGE_REPO:$MAJOR_TAG" -f "$DOCKERFILE_PATH" . 2>&1 + docker build -t "${IMAGE_REPO}:${MAJOR_TAG}" -f "${DOCKERFILE_PATH}" . 2>&1 ####################### # Load the error code # @@ -331,7 +331,7 @@ BuildImage() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [tag] Dockerfile!${NC}" exit 1 @@ -349,14 +349,14 @@ UploadImage() { ################ echo "" echo "----------------------------------------------" - echo "Uploading the DockerFile image to $REGISTRY..." + echo "Uploading the DockerFile image to ${REGISTRY}..." echo "----------------------------------------------" echo "" ############################################ # Upload the docker image that was created # ############################################ - docker push "$IMAGE_REPO:$IMAGE_VERSION" 2>&1 + docker push "${IMAGE_REPO}:${IMAGE_VERSION}" 2>&1 ####################### # Load the error code # @@ -366,20 +366,20 @@ UploadImage() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] Dockerfile!${NC}" exit 1 else # SUCCESS - echo -e "${NC}${F[B]}Successfully Uploaded Docker image:${F[W]}[$IMAGE_VERSION]${F[B]} to ${F[C]}$REGISTRY${F[B]}!${NC}" + echo -e "${NC}${F[B]}Successfully Uploaded Docker image:${F[W]}[${IMAGE_VERSION}]${F[B]} to ${F[C]}${REGISTRY}${F[B]}!${NC}" fi ######################### # Get Image information # ######################### IFS=$'\n' # Set the delimit to newline - GET_INFO_CMD=$(docker images | grep "$IMAGE_REPO" | grep "$IMAGE_VERSION" 2>&1) + GET_INFO_CMD=$(docker images | grep "${IMAGE_REPO}" | grep "${IMAGE_VERSION}" 2>&1) ####################### # Load the error code # @@ -389,18 +389,18 @@ UploadImage() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get information about built Image!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GET_INFO_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_INFO_CMD}]${NC}" exit 1 else ################ # Get the data # ################ - REPO=$(echo "$GET_INFO_CMD" | awk '{print $1}') - TAG=$(echo "$GET_INFO_CMD" | awk '{print $2}') - IMAGE_ID=$(echo "$GET_INFO_CMD" | awk '{print $3}') + REPO=$(echo "${GET_INFO_CMD}" | awk '{print ${1}}') + TAG=$(echo "${GET_INFO_CMD}" | awk '{print ${2}}') + IMAGE_ID=$(echo "${GET_INFO_CMD}" | awk '{print ${3}}') SIZE="${GET_INFO_CMD##* }" ################### @@ -408,21 +408,21 @@ UploadImage() { ################### echo "----------------------------------------------" echo "Docker Image Details:" - echo "Repository:[$REPO]" - echo "Tag:[$TAG]" - echo "Image_ID:[$IMAGE_ID]" - echo "Size:[$SIZE]" + echo "Repository:[${REPO}]" + echo "Tag:[${TAG}]" + echo "Image_ID:[${IMAGE_ID}]" + echo "Size:[${SIZE}]" echo "----------------------------------------------" fi ############################################################### # Check if we need to upload the major tagged version as well # ############################################################### - if [ $UPDATE_MAJOR_TAG -eq 1 ]; then + if [ ${UPDATE_MAJOR_TAG} -eq 1 ]; then ############################################ # Upload the docker image that was created # ############################################ - docker push "$IMAGE_REPO:$MAJOR_TAG" 2>&1 + docker push "${IMAGE_REPO}:${MAJOR_TAG}" 2>&1 ####################### # Load the error code # @@ -432,13 +432,13 @@ UploadImage() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[$MAJOR_TAG] Dockerfile!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} failed to [upload] MAJOR_TAG:[${MAJOR_TAG}] Dockerfile!${NC}" exit 1 else # SUCCESS - echo -e "${NC}${F[B]}Successfully Uploaded TAG:${F[W]}[$MAJOR_TAG]${F[B]} of Docker image to ${F[C]}$REGISTRY${F[B]}!${NC}" + echo -e "${NC}${F[B]}Successfully Uploaded TAG:${F[W]}[${MAJOR_TAG}]${F[B]} of Docker image to ${F[C]}${REGISTRY}${F[B]}!${NC}" fi fi } @@ -473,23 +473,23 @@ BuildImage ###################### # Login to DockerHub # ###################### -if [[ $REGISTRY == "Docker" ]]; then +if [[ ${REGISTRY} == "Docker" ]]; then # Authenticate "Username" "Password" "Url" "Name" - Authenticate "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "" "Dockerhub" + Authenticate "${DOCKER_USERNAME}" "${DOCKER_PASSWORD}" "" "Dockerhub" #################################### # Login to GitHub Package Registry # #################################### -elif [[ $REGISTRY == "GPR" ]]; then +elif [[ ${REGISTRY} == "GPR" ]]; then # Authenticate "Username" "Password" "Url" "Name" - Authenticate "$GPR_USERNAME" "$GPR_TOKEN" "https://docker.pkg.github.com" "GitHub Package Registry" + Authenticate "${GPR_USERNAME}" "${GPR_TOKEN}" "https://docker.pkg.github.com" "GitHub Package Registry" else ######### # ERROR # ######### echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Registry not set correctly!${NC}" - echo "Registry:[$REGISTRY]" + echo "Registry:[${REGISTRY}]" exit 1 fi diff --git a/.vscode/testlinter.sh b/.vscode/testlinter.sh index 50427028..5094c89e 100644 --- a/.vscode/testlinter.sh +++ b/.vscode/testlinter.sh @@ -12,9 +12,9 @@ CODE_PATH='/tmp/lint' # Path to code base ################## # Check the path # ################## -if [ ! -L $CODE_PATH ]; then +if [ ! -L ${CODE_PATH} ]; then # Create symbolic link - ln -s "$PWD"/.automation/test $CODE_PATH + ln -s "${PWD}"/.automation/test ${CODE_PATH} fi ######################### @@ -23,4 +23,4 @@ fi export RUN_LOCAL=true # shellcheck source=/dev/null -source "$PWD"/lib/linter.sh +source "${PWD}"/lib/linter.sh diff --git a/Dockerfile b/Dockerfile index 242e066c..c4e37c19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -126,7 +126,7 @@ ENV ARM_TTK_PSD1="${ARM_TTK_DIRECTORY}/arm-ttk-master/arm-ttk/arm-ttk.psd1" RUN curl -sLO "${ARM_TTK_URI}" \ && unzip "${ARM_TTK_NAME}" -d "${ARM_TTK_DIRECTORY}" \ && rm "${ARM_TTK_NAME}" \ - && ln -sTf "$ARM_TTK_PSD1" /usr/bin/arm-ttk + && ln -sTf "${ARM_TTK_PSD1}" /usr/bin/arm-ttk ###################### # Install shellcheck # diff --git a/TEMPLATES/.powershell-psscriptanalyzer.psd1 b/TEMPLATES/.powershell-psscriptanalyzer.psd1 index ab462662..f4bbd6b5 100644 --- a/TEMPLATES/.powershell-psscriptanalyzer.psd1 +++ b/TEMPLATES/.powershell-psscriptanalyzer.psd1 @@ -6,7 +6,7 @@ # 'Error' # 'Warning' #) - #IncludeDefaultRules=$true + #IncludeDefaultRules=${true} #ExcludeRules = @( # 'PSAvoidUsingWriteHost', # 'MyCustomRuleName' @@ -15,4 +15,4 @@ # 'PSAvoidUsingWriteHost', # 'MyCustomRuleName' #) -} \ No newline at end of file +} diff --git a/lib/buildFileList.sh b/lib/buildFileList.sh index 7e105d32..11462989 100755 --- a/lib/buildFileList.sh +++ b/lib/buildFileList.sh @@ -16,7 +16,7 @@ function BuildFileList() { ################ # print header # ################ - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then echo "" echo "----------------------------------------------" echo "Pulling in code history and branches..." @@ -26,8 +26,8 @@ function BuildFileList() { # Switch codebase back to the default branch to get a list of all files changed # ################################################################################# SWITCH_CMD=$( - git -C "$GITHUB_WORKSPACE" pull --quiet - git -C "$GITHUB_WORKSPACE" checkout "$DEFAULT_BRANCH" 2>&1 + git -C "${GITHUB_WORKSPACE}" pull --quiet + git -C "${GITHUB_WORKSPACE}" checkout "${DEFAULT_BRANCH}" 2>&1 ) ####################### @@ -38,26 +38,26 @@ function BuildFileList() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Error - echo "Failed to switch to $DEFAULT_BRANCH branch to get files changed!" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH_CMD]${NC}" + echo "Failed to switch to ${DEFAULT_BRANCH} branch to get files changed!" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH_CMD}]${NC}" exit 1 fi ################ # print header # ################ - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then echo "" echo "----------------------------------------------" - echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]" + echo "Generating Diff with:[git diff --name-only '${DEFAULT_BRANCH}..${GITHUB_SHA}' --diff-filter=d]" fi ################################################# # Get the Array of files changed in the commits # ################################################# - mapfile -t RAW_FILE_ARRAY < <(git -C "$GITHUB_WORKSPACE" 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 # @@ -67,7 +67,7 @@ function BuildFileList() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Error echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain a list of all files changed!${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${RAW_FILE_ARRAY[*]}]${NC}" @@ -86,26 +86,26 @@ function BuildFileList() { ########################### # Extract just the file and extension, reverse it, cut off extension, # reverse it back, substitute to lowercase - FILE_TYPE=$(basename "$FILE" | rev | cut -f1 -d'.' | rev | awk '{print tolower($0)}') + FILE_TYPE=$(basename "${FILE}" | rev | cut -f1 -d'.' | rev | awk '{print tolower(${0})}') ############## # Print file # ############## - echo "File:[$FILE], File_type:[$FILE_TYPE]" + echo "File:[${FILE}], File_type:[${FILE_TYPE}]" ######### # DEBUG # ######### - #echo "FILE_TYPE:[$FILE_TYPE]" + #echo "FILE_TYPE:[${FILE_TYPE}]" ##################### # Get the CFN files # ##################### - if [ "$FILE_TYPE" == "yml" ] || [ "$FILE_TYPE" == "yaml" ]; then + if [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_YML+=("$FILE") + FILE_ARRAY_YML+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -114,11 +114,11 @@ function BuildFileList() { ##################################### # Check if the file is CFN template # ##################################### - if DetectCloudFormationFile "$FILE"; then + if DetectCloudFormationFile "${FILE}"; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_CFN+=("$FILE") + FILE_ARRAY_CFN+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # @@ -128,37 +128,37 @@ function BuildFileList() { ###################### # Get the JSON files # ###################### - elif [ "$FILE_TYPE" == "json" ]; then + elif [ "${FILE_TYPE}" == "json" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_JSON+=("$FILE") + FILE_ARRAY_JSON+=("${FILE}") ############################ # Check if file is OpenAPI # ############################ - if DetectOpenAPIFile "$FILE"; then + if DetectOpenAPIFile "${FILE}"; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_OPENAPI+=("$FILE") + FILE_ARRAY_OPENAPI+=("${FILE}") fi ############################ # Check if file is ARM # ############################ - if DetectARMFile "$FILE"; then + if DetectARMFile "${FILE}"; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_ARM+=("$FILE") + FILE_ARRAY_ARM+=("${FILE}") fi ##################################### # Check if the file is CFN template # ##################################### - if DetectCloudFormationFile "$FILE"; then + if DetectCloudFormationFile "${FILE}"; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_CFN+=("$FILE") + FILE_ARRAY_CFN+=("${FILE}") fi ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # @@ -167,11 +167,11 @@ function BuildFileList() { ##################### # Get the XML files # ##################### - elif [ "$FILE_TYPE" == "xml" ]; then + elif [ "${FILE_TYPE}" == "xml" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_XML+=("$FILE") + FILE_ARRAY_XML+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -179,19 +179,19 @@ function BuildFileList() { ########################## # Get the MARKDOWN files # ########################## - elif [ "$FILE_TYPE" == "md" ]; then + elif [ "${FILE_TYPE}" == "md" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_MARKDOWN+=("$FILE") + FILE_ARRAY_MARKDOWN+=("${FILE}") ###################### # Get the BASH files # ###################### - elif [ "$FILE_TYPE" == "sh" ]; then + elif [ "${FILE_TYPE}" == "sh" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_BASH+=("$FILE") + FILE_ARRAY_BASH+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -199,11 +199,11 @@ function BuildFileList() { ###################### # Get the PERL files # ###################### - elif [ "$FILE_TYPE" == "pl" ]; then + elif [ "${FILE_TYPE}" == "pl" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_PERL+=("$FILE") + FILE_ARRAY_PERL+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -211,13 +211,13 @@ function BuildFileList() { ###################### # Get the RAKU files # ###################### - elif [ "$FILE_TYPE" == "raku" ] || [ "$FILE_TYPE" == "rakumod" ] \ - || [ "$FILE_TYPE" == "rakutest" ] || [ "$FILE_TYPE" == "pm6" ] \ - || [ "$FILE_TYPE" == "pl6" ] || [ "$FILE_TYPE" == "p6" ] ; then + elif [ "${FILE_TYPE}" == "raku" ] || [ "${FILE_TYPE}" == "rakumod" ] \ + || [ "${FILE_TYPE}" == "rakutest" ] || [ "${FILE_TYPE}" == "pm6" ] \ + || [ "${FILE_TYPE}" == "pl6" ] || [ "${FILE_TYPE}" == "p6" ] ; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_RAKU+=("$FILE") + FILE_ARRAY_RAKU+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -225,11 +225,11 @@ function BuildFileList() { ###################### # Get the PHP files # ###################### - elif [ "$FILE_TYPE" == "php" ]; then + elif [ "${FILE_TYPE}" == "php" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_PHP+=("$FILE") + FILE_ARRAY_PHP+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -237,11 +237,11 @@ function BuildFileList() { ###################### # Get the RUBY files # ###################### - elif [ "$FILE_TYPE" == "rb" ]; then + elif [ "${FILE_TYPE}" == "rb" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_RUBY+=("$FILE") + FILE_ARRAY_RUBY+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -249,11 +249,11 @@ function BuildFileList() { ######################## # Get the PYTHON files # ######################## - elif [ "$FILE_TYPE" == "py" ]; then + elif [ "${FILE_TYPE}" == "py" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_PYTHON+=("$FILE") + FILE_ARRAY_PYTHON+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -261,11 +261,11 @@ function BuildFileList() { ######################## # Get the COFFEE files # ######################## - elif [ "$FILE_TYPE" == "coffee" ]; then + elif [ "${FILE_TYPE}" == "coffee" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_COFFEESCRIPT+=("$FILE") + FILE_ARRAY_COFFEESCRIPT+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -273,12 +273,12 @@ function BuildFileList() { ############################ # Get the JavaScript files # ############################ - elif [ "$FILE_TYPE" == "js" ]; then + elif [ "${FILE_TYPE}" == "js" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_JAVASCRIPT_ES+=("$FILE") - FILE_ARRAY_JAVASCRIPT_STANDARD+=("$FILE") + FILE_ARRAY_JAVASCRIPT_ES+=("${FILE}") + FILE_ARRAY_JAVASCRIPT_STANDARD+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -286,11 +286,11 @@ function BuildFileList() { ############################ # Get the JSX files # ############################ - elif [ "$FILE_TYPE" == "jsx" ]; then + elif [ "${FILE_TYPE}" == "jsx" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_JSX+=("$FILE") + FILE_ARRAY_JSX+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -298,11 +298,11 @@ function BuildFileList() { ############################ # Get the TSX files # ############################ - elif [ "$FILE_TYPE" == "tsx" ]; then + elif [ "${FILE_TYPE}" == "tsx" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_TSX+=("$FILE") + FILE_ARRAY_TSX+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -313,12 +313,12 @@ function BuildFileList() { ############################ # Get the TypeScript files # ############################ - elif [ "$FILE_TYPE" == "ts" ]; then + elif [ "${FILE_TYPE}" == "ts" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_TYPESCRIPT_ES+=("$FILE") - FILE_ARRAY_TYPESCRIPT_STANDARD+=("$FILE") + FILE_ARRAY_TYPESCRIPT_ES+=("${FILE}") + FILE_ARRAY_TYPESCRIPT_STANDARD+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -326,11 +326,11 @@ function BuildFileList() { ######################## # Get the Golang files # ######################## - elif [ "$FILE_TYPE" == "go" ]; then + elif [ "${FILE_TYPE}" == "go" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_GO+=("$FILE") + FILE_ARRAY_GO+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -338,11 +338,11 @@ function BuildFileList() { ########################### # Get the Terraform files # ########################### - elif [ "$FILE_TYPE" == "tf" ]; then + elif [ "${FILE_TYPE}" == "tf" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_TERRAFORM+=("$FILE") + FILE_ARRAY_TERRAFORM+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -350,34 +350,34 @@ function BuildFileList() { ########################### # Get the Powershell files # ########################### - elif [ "$FILE_TYPE" == "ps1" ]; then + elif [ "${FILE_TYPE}" == "ps1" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_POWERSHELL+=("$FILE") - elif [ "$FILE_TYPE" == "css" ]; then + FILE_ARRAY_POWERSHELL+=("${FILE}") + elif [ "${FILE_TYPE}" == "css" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_CSS+=("$FILE") + FILE_ARRAY_CSS+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "env" ]; then + elif [ "${FILE_TYPE}" == "env" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_ENV+=("$FILE") + FILE_ARRAY_ENV+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "kt" ] || [ "$FILE_TYPE" == "kts" ]; then + elif [ "${FILE_TYPE}" == "kt" ] || [ "${FILE_TYPE}" == "kts" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_KOTLIN+=("$FILE") + FILE_ARRAY_KOTLIN+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -385,47 +385,47 @@ function BuildFileList() { ############################ # Get the Protocol Buffers files # ############################ - elif [ "$FILE_TYPE" == "dart" ]; then + elif [ "${FILE_TYPE}" == "dart" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_DART+=("$FILE") + FILE_ARRAY_DART+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "proto" ]; then + elif [ "${FILE_TYPE}" == "proto" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_PROTOBUF+=("$FILE") + FILE_ARRAY_PROTOBUF+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE" == "dockerfile" ] || [ "$FILE_TYPE" == "dockerfile" ]; then + elif [ "${FILE}" == "dockerfile" ] || [ "${FILE_TYPE}" == "dockerfile" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_DOCKER+=("$FILE") + FILE_ARRAY_DOCKER+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "clj" ] || [ "$FILE_TYPE" == "cljs" ] || [ "$FILE_TYPE" == "cljc" ] || [ "$FILE_TYPE" == "edn" ]; then + elif [ "${FILE_TYPE}" == "clj" ] || [ "${FILE_TYPE}" == "cljs" ] || [ "${FILE_TYPE}" == "cljc" ] || [ "${FILE_TYPE}" == "edn" ]; then ################################ # Append the file to the array # ################################ - FILE_ARRAY_CLOJURE+=("$FILE") + FILE_ARRAY_CLOJURE+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [ "$FILE_TYPE" == "html" ]; then + elif [ "${FILE_TYPE}" == "html" ]; then ################################ # Append the file to the array # ##############################p## - FILE_ARRAY_HTML+=("$FILE") + FILE_ARRAY_HTML+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -434,12 +434,12 @@ function BuildFileList() { ############################################## # Use file to see if we can parse what it is # ############################################## - GET_FILE_TYPE_CMD=$(file "$FILE" 2>&1) + GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1) ################# # Check if bash # ################# - if [[ $GET_FILE_TYPE_CMD == *"Bourne-Again shell script"* ]]; then + if [[ ${GET_FILE_TYPE_CMD} == *"Bourne-Again shell script"* ]]; then ####################### # It is a bash script # ####################### @@ -448,12 +448,12 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_BASH+=("$FILE") + FILE_ARRAY_BASH+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## READ_ONLY_CHANGE_FLAG=1 - elif [[ $GET_FILE_TYPE_CMD == *"Ruby script"* ]]; then + elif [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then ####################### # It is a Ruby script # ####################### @@ -462,7 +462,7 @@ function BuildFileList() { ################################ # Append the file to the array # ################################ - FILE_ARRAY_RUBY+=("$FILE") + FILE_ARRAY_RUBY+=("${FILE}") ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -471,7 +471,7 @@ function BuildFileList() { ############################ # Extension was not found! # ############################ - echo -e "${NC}${F[Y]} - WARN!${NC} Failed to get filetype for:[$FILE]!${NC}" + echo -e "${NC}${F[Y]} - WARN!${NC} Failed to get filetype for:[${FILE}]!${NC}" ########################################################## # Set the READ_ONLY_CHANGE_FLAG since this could be exec # ########################################################## @@ -485,7 +485,7 @@ function BuildFileList() { ######################################### # Need to switch back to branch of code # ######################################### - SWITCH2_CMD=$(git -C "$GITHUB_WORKSPACE" checkout --progress --force "$GITHUB_SHA" 2>&1) + SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1) ####################### # Load the error code # @@ -495,10 +495,10 @@ function BuildFileList() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Error echo "Failed to switch back to branch!" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$SWITCH2_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${SWITCH2_CMD}]${NC}" exit 1 fi diff --git a/lib/linter.sh b/lib/linter.sh index 030bb170..a4310c38 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -26,66 +26,66 @@ DEFAULT_RULES_LOCATION='/action/lib/.automation' # Defaul LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # YAML Vars YAML_FILE_NAME='.yaml-lint.yml' # Name of the file -YAML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$YAML_FILE_NAME" # Path to the yaml lint rules +YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the yaml lint rules # MD Vars MARKDOWN_FILE_NAME='.markdown-lint.yml' # Name of the file -MARKDOWN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$MARKDOWN_FILE_NAME" # Path to the markdown lint rules +MARKDOWN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${MARKDOWN_FILE_NAME}" # Path to the markdown lint rules # Python Vars PYTHON_FILE_NAME='.python-lint' # Name of the file -PYTHON_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PYTHON_FILE_NAME" # Path to the python lint rules +PYTHON_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PYTHON_FILE_NAME}" # Path to the python lint rules # Cloudformation Vars CFN_FILE_NAME='.cfnlintrc.yml' # Name of the file -CFN_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CFN_FILE_NAME" # Path to the cloudformation lint rules +CFN_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CFN_FILE_NAME}" # Path to the cloudformation lint rules # Ruby Vars RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}" # Name of the file -RUBY_LINTER_RULES="$DEFAULT_RULES_LOCATION/$RUBY_FILE_NAME" # Path to the ruby lint rules +RUBY_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${RUBY_FILE_NAME}" # Path to the ruby lint rules # Coffee Vars COFFEE_FILE_NAME='.coffee-lint.json' # Name of the file -COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to the coffeescript lint rules +COFFEESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${COFFEE_FILE_NAME}" # Path to the coffeescript lint rules # Javascript Vars JAVASCRIPT_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules +JAVASCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${JAVASCRIPT_FILE_NAME}" # Path to the Javascript lint rules JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Typescript Vars TYPESCRIPT_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" # Name of the file -TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules +TYPESCRIPT_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TYPESCRIPT_FILE_NAME}" # Path to the Typescript lint rules TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard # Ansible Vars ANSIBLE_FILE_NAME='.ansible-lint.yml' # Name of the file -ANSIBLE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ANSIBLE_FILE_NAME" # Path to the Ansible lint rules +ANSIBLE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ANSIBLE_FILE_NAME}" # Path to the Ansible lint rules # Docker Vars DOCKER_FILE_NAME='.dockerfilelintrc' # Name of the file -DOCKER_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DOCKER_FILE_NAME" # Path to the Docker lint rules +DOCKER_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DOCKER_FILE_NAME}" # Path to the Docker lint rules # Golang Vars GO_FILE_NAME='.golangci.yml' # Name of the file -GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to the Go lint rules +GO_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${GO_FILE_NAME}" # Path to the Go lint rules # Terraform Vars TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file -TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules +TERRAFORM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${TERRAFORM_FILE_NAME}" # Path to the Terraform lint rules # Powershell Vars POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file -POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules +POWERSHELL_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${POWERSHELL_FILE_NAME}" # Path to the Powershell lint rules # Azure Resource Manager Vars ARM_FILE_NAME='.arm-ttk.psd1' # Name of the file -ARM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$ARM_FILE_NAME" # Path to the ARM lint rules +ARM_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${ARM_FILE_NAME}" # Path to the ARM lint rules # CSS Vars CSS_FILE_NAME='.stylelintrc.json' # Name of the file -CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules +CSS_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CSS_FILE_NAME}" # Path to the CSS lint rules # OpenAPI Vars OPENAPI_FILE_NAME='.openapirc.yml' # Name of the file -OPENAPI_LINTER_RULES="$DEFAULT_RULES_LOCATION/$OPENAPI_FILE_NAME" # Path to the OpenAPI lint rules +OPENAPI_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${OPENAPI_FILE_NAME}" # Path to the OpenAPI lint rules # Protocol Buffers Vars PROTOBUF_FILE_NAME='.protolintrc.yml' # Name of the file -PROTOBUF_LINTER_RULES="$DEFAULT_RULES_LOCATION/$PROTOBUF_FILE_NAME" # Path to the Protocol Buffers lint rules +PROTOBUF_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${PROTOBUF_FILE_NAME}" # Path to the Protocol Buffers lint rules # Clojure Vars CLOJURE_FILE_NAME='.clj-kondo/config.edn' # Name of the file -CLOJURE_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CLOJURE_FILE_NAME" # Path to the Clojure lint rules +CLOJURE_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${CLOJURE_FILE_NAME}" # Path to the Clojure lint rules # Dart Vars DART_FILE_NAME='analysis_options.yaml' # Name of the file -DART_LINTER_RULES="$DEFAULT_RULES_LOCATION/$DART_FILE_NAME" # Path to the DART lint rules +DART_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${DART_FILE_NAME}" # Path to the DART lint rules # HTML Vars HTML_FILE_NAME='.htmlhintrc' # Name of the file -HTML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$HTML_FILE_NAME" # Path to the CSS lint rules +HTML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${HTML_FILE_NAME}" # Path to the CSS lint rules ####################################### # Linter array for information prints # @@ -171,7 +171,7 @@ DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally DEFAULT_RUN_LOCAL='false' # Default value for debugging locally DEFAULT_TEST_CASE_RUN='false' # Flag to tell code to run only test cases -DEFAULT_IFS="$IFS" # Get the Default IFS for updating +DEFAULT_IFS="${IFS}" # Get the Default IFS for updating ############################################################### # Default Vars that are called in Subs and need to be ignored # @@ -184,7 +184,7 @@ READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if echo "${READ_ONLY_CHANGE_FLAG}" > /dev/null 2>&1 || true # Workaround SC2034 TEST_CASE_FOLDER='.automation/test' # Folder for test cases we should always ignore echo "${TEST_CASE_FOLDER}" > /dev/null 2>&1 || true # Workaround SC2034 -DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory +DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory echo "${DEFAULT_ANSIBLE_DIRECTORY}" > /dev/null 2>&1 || true # Workaround SC2034 WARNING_ARRAY_TEST=() # Array of warning linters that did not have an expected test result. echo "${WARNING_ARRAY_TEST[*]}" > /dev/null 2>&1 || true # Workaround SC2034 @@ -309,15 +309,15 @@ GetLinterVersions() { ################### # Get the version # ################### - if [[ "$LINTER" == "arm-ttk" ]]; then + if [[ "${LINTER}" == "arm-ttk" ]]; then # Need specific command for ARM - mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "$ARM_TTK_PSD1" | xargs 2>&1) - elif [[ "$LINTER" == "protolint" ]]; then + mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) + elif [[ "${LINTER}" == "protolint" ]]; then # Need specific command for Protolint mapfile -t GET_VERSION_CMD < <(echo "--version not supported") else # Standard version command - mapfile -t GET_VERSION_CMD < <("$LINTER" --version 2>&1) + mapfile -t GET_VERSION_CMD < <("${LINTER}" --version 2>&1) fi ####################### @@ -328,13 +328,13 @@ GetLinterVersions() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then - echo -e "${NC}[$LINTER]: ${F[Y]}WARN!${NC} Failed to get version info for:${NC}" + if [ ${ERROR_CODE} -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then + echo -e "${NC}[${LINTER}]: ${F[Y]}WARN!${NC} Failed to get version info for:${NC}" else ########################## # Print the version info # ########################## - echo -e "${NC}${F[B]}Successfully found version for ${F[W]}[$LINTER]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}" + echo -e "${NC}${F[B]}Successfully found version for ${F[W]}[${LINTER}]${F[B]}: ${F[W]}${GET_VERSION_CMD[*]}${NC}" fi done @@ -352,7 +352,7 @@ GetLinterRules() { ################ # Pull in vars # ################ - LANGUAGE_NAME="$1" # Name of the language were looking for + LANGUAGE_NAME="${1}" # Name of the language were looking for ####################################################### # Need to create the variables for the real variables # @@ -363,20 +363,20 @@ GetLinterRules() { ##################################### # Validate we have the linter rules # ##################################### - if [ -f "$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}" ]; then + if [ -f "${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" ]; then echo "----------------------------------------------" echo "User provided file:[${!LANGUAGE_FILE_NAME}], setting rules file..." ######################################## # Update the path to the file location # ######################################## - eval "${LANGUAGE_LINTER_RULES}=$GITHUB_WORKSPACE/$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}" + eval "${LANGUAGE_LINTER_RULES}=${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}" else ######################################################## # No user default provided, using the template default # ######################################################## - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then - echo " -> Codebase does NOT have file:[$LINTER_RULES_PATH/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then + echo " -> Codebase does NOT have file:[${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]" fi fi } @@ -386,13 +386,13 @@ GetStandardRules() { ################ # Pull In Vars # ################ - LINTER="$1" # Type: javascript | typescript + LINTER="${1}" # Type: javascript | typescript ######################################################################### # Need to get the ENV vars from the linter rules to run in command line # ######################################################################### # Copy orig IFS to var - ORIG_IFS="$IFS" + ORIG_IFS="${IFS}" # Set the IFS to newline IFS=$'\n' @@ -401,10 +401,10 @@ GetStandardRules() { ######################################### # Only env vars that are marked as true GET_ENV_ARRAY=() - if [[ $LINTER == "javascript" ]]; then - mapfile -t GET_ENV_ARRAY < <(yq .env "$JAVASCRIPT_LINTER_RULES" | grep true) - elif [[ $LINTER == "typescript" ]]; then - mapfile -t GET_ENV_ARRAY < <(yq .env "$TYPESCRIPT_LINTER_RULES" | grep true) + if [[ ${LINTER} == "javascript" ]]; then + mapfile -t GET_ENV_ARRAY < <(yq .env "${JAVASCRIPT_LINTER_RULES}" | grep true) + elif [[ ${LINTER} == "typescript" ]]; then + mapfile -t GET_ENV_ARRAY < <(yq .env "${TYPESCRIPT_LINTER_RULES}" | grep true) fi ####################### @@ -415,7 +415,7 @@ GetStandardRules() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # ERROR echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to gain list of ENV vars to load!${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GET_ENV_ARRAY[*]}]${NC}" @@ -426,7 +426,7 @@ GetStandardRules() { # Set IFS back to normal # ########################## # Set IFS back to Orig - IFS="$ORIG_IFS" + IFS="${ORIG_IFS}" ###################### # Set the env string # @@ -445,16 +445,16 @@ GetStandardRules() { # Get the env to add to string # ################################ ENV="$(echo "${ENV}" | cut -d'"' -f2)" - # echo "ENV:[$ENV]" + # echo "ENV:[${ENV}]" ENV_STRING+="--env ${ENV} " done ######################################### # Remove trailing and ending whitespace # ######################################### - if [[ $LINTER == "javascript" ]]; then + if [[ ${LINTER} == "javascript" ]]; then JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" - elif [[ $LINTER == "typescript" ]]; then + elif [[ ${LINTER} == "typescript" ]]; then TYPESCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" fi } @@ -464,12 +464,12 @@ DetectOpenAPIFile() { ################ # Pull in vars # ################ - FILE="$1" + FILE="${1}" ############################### # Check the file for keywords # ############################### - grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "$FILE" > /dev/null + grep -E '"openapi":|"swagger":|^openapi:|^swagger:' "${FILE}" > /dev/null ####################### # Load the error code # @@ -479,7 +479,7 @@ DetectOpenAPIFile() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -eq 0 ]; then + if [ ${ERROR_CODE} -eq 0 ]; then ######################## # Found string in file # ######################## @@ -497,12 +497,12 @@ DetectARMFile() { ################ # Pull in vars # ################ - FILE="$1" # Name of the file/path we are validating + FILE="${1}" # Name of the file/path we are validating ############################### # Check the file for keywords # ############################### - grep -E 'schema.management.azure.com' "$FILE" > /dev/null + grep -E 'schema.management.azure.com' "${FILE}" > /dev/null ####################### # Load the error code # @@ -512,7 +512,7 @@ DetectARMFile() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -eq 0 ]; then + if [ ${ERROR_CODE} -eq 0 ]; then ######################## # Found string in file # ######################## @@ -530,14 +530,14 @@ DetectCloudFormationFile() { ################ # Pull in Vars # ################ - FILE="$1" # File that we need to validate + FILE="${1}" # File that we need to validate # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-formats.html # AWSTemplateFormatVersion is optional ####################################### # Check if file has AWS Template info # ####################################### - if grep 'AWSTemplateFormatVersion' "$FILE" > /dev/null; then + if grep 'AWSTemplateFormatVersion' "${FILE}" > /dev/null; then # Found it return 0 fi @@ -545,7 +545,7 @@ DetectCloudFormationFile() { ################################################### # Check if file has AWSTemplateFormatVersion info # ################################################### - if shyaml --quiet get-type AWSTemplateFormatVersion > /dev/null < "$FILE"; then + if shyaml --quiet get-type AWSTemplateFormatVersion > /dev/null < "${FILE}"; then # Found it return 0 fi @@ -553,9 +553,9 @@ DetectCloudFormationFile() { ############################### # check if file has resources # ############################### - if jq -e 'has("Resources")' > /dev/null 2>&1 < "$FILE"; then + if jq -e 'has("Resources")' > /dev/null 2>&1 < "${FILE}"; then # Check if AWS Alexa or custom - if jq ".Resources[].Type" 2> /dev/null | grep -q -E "(AWS|Alexa|Custom)" < "$FILE"; then + if jq ".Resources[].Type" 2> /dev/null | grep -q -E "(AWS|Alexa|Custom)" < "${FILE}"; then # Found it return 0 fi @@ -564,7 +564,7 @@ DetectCloudFormationFile() { ################################ # See if it contains resources # ################################ - if shyaml values-0 Resources 2> /dev/null | grep -q -E "Type: (AWS|Alexa|Custom)" < "$FILE"; then + if shyaml values-0 Resources 2> /dev/null | grep -q -E "Type: (AWS|Alexa|Custom)" < "${FILE}"; then # Found it return 0 fi @@ -587,11 +587,11 @@ GetGitHubVars() { ############################### # Get the Run test cases flag # ############################### - if [ -z "$TEST_CASE_RUN" ]; then + if [ -z "${TEST_CASE_RUN}" ]; then ################################## # No flag passed, set to default # ################################## - TEST_CASE_RUN="$DEFAULT_TEST_CASE_RUN" + TEST_CASE_RUN="${DEFAULT_TEST_CASE_RUN}" fi ############################### @@ -602,11 +602,11 @@ GetGitHubVars() { ########################## # Get the run local flag # ########################## - if [ -z "$RUN_LOCAL" ]; then + if [ -z "${RUN_LOCAL}" ]; then ################################## # No flag passed, set to default # ################################## - RUN_LOCAL="$DEFAULT_RUN_LOCAL" + RUN_LOCAL="${DEFAULT_RUN_LOCAL}" fi ############################### @@ -617,7 +617,7 @@ GetGitHubVars() { ################################# # Check if were running locally # ################################# - if [[ $RUN_LOCAL != "false" ]]; then + if [[ ${RUN_LOCAL} != "false" ]]; then ########################################## # We are running locally for a debug run # ########################################## @@ -627,16 +627,16 @@ GetGitHubVars() { ############################ # Set the GITHUB_WORKSPACE # ############################ - if [ -z "$GITHUB_WORKSPACE" ]; then - GITHUB_WORKSPACE="$DEFAULT_WORKSPACE" + if [ -z "${GITHUB_WORKSPACE}" ]; then + GITHUB_WORKSPACE="${DEFAULT_WORKSPACE}" fi - if [ ! -d "$GITHUB_WORKSPACE" ]; then + if [ ! -d "${GITHUB_WORKSPACE}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Provided volume is not a directory!${NC}" exit 1 fi - echo "Linting all files in mapped directory:[$DEFAULT_WORKSPACE]" + echo "Linting all files in mapped directory:[${DEFAULT_WORKSPACE}]" # No need to touch or set the GITHUB_SHA # No need to touch or set the GITHUB_EVENT_PATH @@ -646,39 +646,39 @@ GetGitHubVars() { ################################# # Set the VALIDATE_ALL_CODEBASE # ################################# - VALIDATE_ALL_CODEBASE="$DEFAULT_VALIDATE_ALL_CODEBASE" + VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" else ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_SHA" ]; then + if [ -z "${GITHUB_SHA}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_SHA]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_SHA]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_SHA}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[$GITHUB_SHA]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_SHA]${F[B]}, value:${F[W]}[${GITHUB_SHA}]${NC}" fi ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_WORKSPACE" ]; then + if [ -z "${GITHUB_WORKSPACE}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_WORKSPACE]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_WORKSPACE]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_WORKSPACE}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[$GITHUB_WORKSPACE]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_WORKSPACE]${F[B]}, value:${F[W]}[${GITHUB_WORKSPACE}]${NC}" fi ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_EVENT_PATH" ]; then + if [ -z "${GITHUB_EVENT_PATH}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_EVENT_PATH]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_EVENT_PATH]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_EVENT_PATH}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[$GITHUB_EVENT_PATH]${F[B]}${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_EVENT_PATH]${F[B]}, value:${F[W]}[${GITHUB_EVENT_PATH}]${F[B]}${NC}" fi ################################################## @@ -688,42 +688,42 @@ GetGitHubVars() { ###################### # Get the GitHub Org # ###################### - GITHUB_ORG=$(jq -r '.repository.owner.login' < "$GITHUB_EVENT_PATH") + GITHUB_ORG=$(jq -r '.repository.owner.login' < "${GITHUB_EVENT_PATH}") ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_ORG" ]; then + if [ -z "${GITHUB_ORG}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_ORG]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_ORG]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_ORG}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[$GITHUB_ORG]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_ORG]${F[B]}, value:${F[W]}[${GITHUB_ORG}]${NC}" fi ####################### # Get the GitHub Repo # ####################### - GITHUB_REPO=$(jq -r '.repository.name' < "$GITHUB_EVENT_PATH") + GITHUB_REPO=$(jq -r '.repository.name' < "${GITHUB_EVENT_PATH}") ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_REPO" ]; then + if [ -z "${GITHUB_REPO}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPO]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_REPO]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPO}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[$GITHUB_REPO]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPO]${F[B]}, value:${F[W]}[${GITHUB_REPO}]${NC}" fi fi ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_TOKEN" ]; then + if [ -z "${GITHUB_TOKEN}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_TOKEN]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_TOKEN]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_TOKEN}]${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Please set a [GITHUB_TOKEN] from the main workflow environment to take advantage of multiple status reports!${NC}" ################################################################################ @@ -742,27 +742,27 @@ GetGitHubVars() { ####################################################################### # Check to see if the multi status is set, and we have a token to use # ####################################################################### - if [ "$MULTI_STATUS" == "true" ] && [ -n "$GITHUB_TOKEN" ]; then + if [ "${MULTI_STATUS}" == "true" ] && [ -n "${GITHUB_TOKEN}" ]; then ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_REPOSITORY" ]; then + if [ -z "${GITHUB_REPOSITORY}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_REPOSITORY]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_REPOSITORY]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_REPOSITORY}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[$GITHUB_REPOSITORY]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_REPOSITORY]${F[B]}, value:${F[W]}[${GITHUB_REPOSITORY}]${NC}" fi ############################ # Validate we have a value # ############################ - if [ -z "$GITHUB_RUN_ID" ]; then + if [ -z "${GITHUB_RUN_ID}" ]; then echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to get [GITHUB_RUN_ID]!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$GITHUB_RUN_ID]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${GITHUB_RUN_ID}]${NC}" exit 1 else - echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[$GITHUB_RUN_ID]${NC}" + echo -e "${NC}${F[B]}Successfully found:${F[W]}[GITHUB_RUN_ID]${F[B]}, value:${F[W]}[${GITHUB_RUN_ID}]${NC}" fi fi } @@ -771,7 +771,7 @@ GetGitHubVars() { function ValidatePowershellModules() { VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1) # If module found, ensure Invoke-ScriptAnalyzer command is available - if [[ $VALIDATE_PSSA_MODULE == "PSScriptAnalyzer" ]]; then + if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1) else # Failed to find module @@ -781,7 +781,7 @@ function ValidatePowershellModules() { ######################################### # validate we found the script analyzer # ######################################### - if [[ $VALIDATE_PSSA_CMD != "Invoke-ScriptAnalyzer" ]]; then + if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then # Failed to find module exit 1 fi @@ -794,16 +794,16 @@ function ValidatePowershellModules() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [$LINTER_NAME] in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE $VALIDATE_PSSA_MODULE] [PSSA_CMD $VALIDATE_PSSA_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]${NC}" exit 1 else # Success - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then - echo -e "${NC}${F[B]}Successfully found module ${F[W]}[$VALIDATE_PSSA_MODULE]${F[B]} in system${NC}" - echo -e "${NC}${F[B]}Successfully found command ${F[W]}[$VALIDATE_PSSA_CMD]${F[B]} in system${NC}" + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then + echo -e "${NC}${F[B]}Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system${NC}" + echo -e "${NC}${F[B]}Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system${NC}" fi fi } @@ -813,8 +813,8 @@ CallStatusAPI() { #################### # Pull in the vars # #################### - LANGUAGE="$1" # langauge that was validated - STATUS="$2" # success | error + LANGUAGE="${1}" # langauge that was validated + STATUS="${2}" # success | error SUCCESS_MSG='No errors were found in the linting process' FAIL_MSG='Errors were detected, please view logs' MESSAGE='' # Message to send to status API @@ -822,29 +822,29 @@ CallStatusAPI() { ###################################### # Check the status to create message # ###################################### - if [ "$STATUS" == "success" ]; then + if [ "${STATUS}" == "success" ]; then # Success - MESSAGE="$SUCCESS_MSG" + MESSAGE="${SUCCESS_MSG}" else # Failure - MESSAGE="$FAIL_MSG" + MESSAGE="${FAIL_MSG}" fi ########################################################## # Check to see if were enabled for multi Status mesaages # ########################################################## - if [ "$MULTI_STATUS" == "true" ]; then + if [ "${MULTI_STATUS}" == "true" ]; then ############################################## # Call the status API to create status check # ############################################## SEND_STATUS_CMD=$(curl -f -s -X POST \ - --url "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \ + --url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}" \ -H 'accept: application/vnd.github.v3+json' \ - -H "authorization: Bearer $GITHUB_TOKEN" \ + -H "authorization: Bearer ${GITHUB_TOKEN}" \ -H 'content-type: application/json' \ - -d "{ \"state\": \"$STATUS\", - \"target_url\": \"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\", - \"description\": \"$MESSAGE\", \"context\": \"--> Linted: $LANGUAGE\" + -d "{ \"state\": \"${STATUS}\", + \"target_url\": \"https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\", + \"description\": \"${MESSAGE}\", \"context\": \"--> Linted: ${LANGUAGE}\" }" 2>&1) ####################### @@ -855,10 +855,10 @@ CallStatusAPI() { ############################## # Check the shell for errors # ############################## - if [ "$ERROR_CODE" -ne 0 ]; then + if [ "${ERROR_CODE}" -ne 0 ]; then # ERROR echo "ERROR! Failed to call GitHub Status API!" - echo "ERROR:[$SEND_STATUS_CMD]" + echo "ERROR:[${SEND_STATUS_CMD}]" # Not going to fail the script on this yet... fi fi @@ -893,7 +893,7 @@ Footer() { ########################### # Build the error counter # ########################### - ERROR_COUNTER="ERRORS_FOUND_$LANGUAGE" + ERROR_COUNTER="ERRORS_FOUND_${LANGUAGE}" ################## # Print if not 0 # @@ -903,19 +903,19 @@ Footer() { ################### # Print the goods # ################### - echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in $LANGUAGE:[${!ERROR_COUNTER}]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERRORS FOUND${NC} in ${LANGUAGE}:[${!ERROR_COUNTER}]${NC}" ######################################### # Create status API for Failed language # ######################################### - CallStatusAPI "$LANGUAGE" "error" + CallStatusAPI "${LANGUAGE}" "error" else # No errors found when linting the language ###################################### # Check if we validated the langauge # ###################################### if [[ "${UNIQUE_LINTED_ARRAY[*]}" =~ ${LANGUAGE} ]]; then - CallStatusAPI "$LANGUAGE" "success" + CallStatusAPI "${LANGUAGE}" "success" fi fi done @@ -930,44 +930,44 @@ Footer() { ################################## # Exit with 0 if errors disabled # ################################## - if [ "$DISABLE_ERRORS" == "true" ]; then - echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[$DISABLE_ERRORS]${NC}" + if [ "${DISABLE_ERRORS}" == "true" ]; then + echo -e "${NC}${F[Y]}WARN!${NC} Exiting with exit code:[0] as:[DISABLE_ERRORS] was set to:[${DISABLE_ERRORS}]${NC}" exit 0 ############################### # Exit with 1 if errors found # ############################### - elif [ "$ERRORS_FOUND_YML" -ne 0 ] || - [ "$ERRORS_FOUND_JSON" -ne 0 ] || - [ "$ERRORS_FOUND_XML" -ne 0 ] || - [ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || - [ "$ERRORS_FOUND_BASH" -ne 0 ] || - [ "$ERRORS_FOUND_PERL" -ne 0 ] || - [ "$ERRORS_FOUND_RAKU" -ne 0 ] || - [ "$ERRORS_FOUND_PHP" -ne 0 ] || - [ "$ERRORS_FOUND_PYTHON" -ne 0 ] || - [ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || - [ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || - [ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] || - [ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -ne 0 ] || - [ "$ERRORS_FOUND_JSX" -ne 0 ] || - [ "$ERRORS_FOUND_TSX" -ne 0 ] || - [ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] || - [ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] || - [ "$ERRORS_FOUND_DOCKER" -ne 0 ] || - [ "$ERRORS_FOUND_GO" -ne 0 ] || - [ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || - [ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || - [ "$ERRORS_FOUND_ARM" -ne 0 ] || - [ "$ERRORS_FOUND_RUBY" -ne 0 ] || - [ "$ERRORS_FOUND_CSS" -ne 0 ] || - [ "$ERRORS_FOUND_CFN" -ne 0 ] || - [ "$ERRORS_FOUND_ENV" -ne 0 ] || - [ "$ERRORS_FOUND_OPENAPI" -ne 0 ] || - [ "$ERRORS_FOUND_PROTOBUF" -ne 0 ] || - [ "$ERRORS_FOUND_CLOJURE" -ne 0 ] || - [ "$ERRORS_FOUND_KOTLIN" -ne 0 ] || - [ "$ERRORS_FOUND_DART" -ne 0 ] || - [ "$ERRORS_FOUND_HTML" -ne 0 ]; then + elif [ "${ERRORS_FOUND_YML}" -ne 0 ] || + [ "${ERRORS_FOUND_JSON}" -ne 0 ] || + [ "${ERRORS_FOUND_XML}" -ne 0 ] || + [ "${ERRORS_FOUND_MARKDOWN}" -ne 0 ] || + [ "${ERRORS_FOUND_BASH}" -ne 0 ] || + [ "${ERRORS_FOUND_PERL}" -ne 0 ] || + [ "${ERRORS_FOUND_RAKU}" -ne 0 ] || + [ "${ERRORS_FOUND_PHP}" -ne 0 ] || + [ "${ERRORS_FOUND_PYTHON}" -ne 0 ] || + [ "${ERRORS_FOUND_COFFEESCRIPT}" -ne 0 ] || + [ "${ERRORS_FOUND_ANSIBLE}" -ne 0 ] || + [ "${ERRORS_FOUND_JAVASCRIPT_ES}" -ne 0 ] || + [ "${ERRORS_FOUND_JAVASCRIPT_STANDARD}" -ne 0 ] || + [ "${ERRORS_FOUND_JSX}" -ne 0 ] || + [ "${ERRORS_FOUND_TSX}" -ne 0 ] || + [ "${ERRORS_FOUND_TYPESCRIPT_ES}" -ne 0 ] || + [ "${ERRORS_FOUND_TYPESCRIPT_STANDARD}" -ne 0 ] || + [ "${ERRORS_FOUND_DOCKER}" -ne 0 ] || + [ "${ERRORS_FOUND_GO}" -ne 0 ] || + [ "${ERRORS_FOUND_TERRAFORM}" -ne 0 ] || + [ "${ERRORS_FOUND_POWERSHELL}" -ne 0 ] || + [ "${ERRORS_FOUND_ARM}" -ne 0 ] || + [ "${ERRORS_FOUND_RUBY}" -ne 0 ] || + [ "${ERRORS_FOUND_CSS}" -ne 0 ] || + [ "${ERRORS_FOUND_CFN}" -ne 0 ] || + [ "${ERRORS_FOUND_ENV}" -ne 0 ] || + [ "${ERRORS_FOUND_OPENAPI}" -ne 0 ] || + [ "${ERRORS_FOUND_PROTOBUF}" -ne 0 ] || + [ "${ERRORS_FOUND_CLOJURE}" -ne 0 ] || + [ "${ERRORS_FOUND_KOTLIN}" -ne 0 ] || + [ "${ERRORS_FOUND_DART}" -ne 0 ] || + [ "${ERRORS_FOUND_HTML}" -ne 0 ]; then # Failed exit echo -e "${NC}${F[R]}Exiting with errors found!${NC}" exit 1 @@ -1057,7 +1057,7 @@ GetLinterRules "HTML" ################################# # Check if were in verbose mode # ################################# -if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then +if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then ################################## # Get and print all version info # ################################## @@ -1067,7 +1067,7 @@ fi ########################################### # Check to see if this is a test case run # ########################################### -if [[ $TEST_CASE_RUN != "false" ]]; then +if [[ ${TEST_CASE_RUN} != "false" ]]; then ############################################# # Set the multi status to off for test runs # @@ -1084,7 +1084,7 @@ fi ############################################# # check flag for validation of all codebase # ############################################# -if [ "$VALIDATE_ALL_CODEBASE" == "false" ]; then +if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then ######################################## # Get list of files changed if env set # ######################################## @@ -1094,18 +1094,18 @@ fi ############### # YML LINTING # ############### -if [ "$VALIDATE_YAML" == "true" ]; then +if [ "${VALIDATE_YAML}" == "true" ]; then ###################### # Lint the Yml Files # ###################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "YML" "yamllint" "yamllint -c $YAML_LINTER_RULES" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YML[@]}" + LintCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILE_ARRAY_YML[@]}" fi ################ # JSON LINTING # ################ -if [ "$VALIDATE_JSON" == "true" ]; then +if [ "${VALIDATE_JSON}" == "true" ]; then ####################### # Lint the json files # ####################### @@ -1116,7 +1116,7 @@ fi ############### # XML LINTING # ############### -if [ "$VALIDATE_XML" == "true" ]; then +if [ "${VALIDATE_XML}" == "true" ]; then ###################### # Lint the XML Files # ###################### @@ -1127,18 +1127,18 @@ fi #################### # MARKDOWN LINTING # #################### -if [ "$VALIDATE_MARKDOWN" == "true" ]; then +if [ "${VALIDATE_MARKDOWN}" == "true" ]; then ########################### # Lint the Markdown Files # ########################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c $MARKDOWN_LINTER_RULES" ".*\.\(md\)\$" "${FILE_ARRAY_MARKDOWN[@]}" + LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "${FILE_ARRAY_MARKDOWN[@]}" fi ################ # BASH LINTING # ################ -if [ "$VALIDATE_BASH" == "true" ]; then +if [ "${VALIDATE_BASH}" == "true" ]; then ####################### # Lint the bash files # ####################### @@ -1149,29 +1149,29 @@ fi ################## # PYTHON LINTING # ################## -if [ "$VALIDATE_PYTHON" == "true" ]; then +if [ "${VALIDATE_PYTHON}" == "true" ]; then ######################### # Lint the python files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON[@]}" + LintCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "${FILE_ARRAY_PYTHON[@]}" fi ############### # CFN LINTING # ############### -if [ "$VALIDATE_CFN" == "true" ]; then +if [ "${VALIDATE_CFN}" == "true" ]; then ################################# # Lint the CloudFormation files # ################################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "CFN" "cfn-lint" "cfn-lint --config-file $CFN_LINTER_RULES" ".*\.\(json\|yml\|yaml\)\$" "${FILE_ARRAY_CFN[@]}" + LintCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "${FILE_ARRAY_CFN[@]}" fi ################ # PERL LINTING # ################ -if [ "$VALIDATE_PERL" == "true" ]; then +if [ "${VALIDATE_PERL}" == "true" ]; then ####################### # Lint the perl files # ####################### @@ -1182,22 +1182,22 @@ fi ################ # RAKU LINTING # ################ -if [ "$VALIDATE_RAKU" == "true" ]; then +if [ "${VALIDATE_RAKU}" == "true" ]; then ####################### # Lint the raku files # ####################### - echo "$GITHUB_WORKSPACE/META6.json" - if [ -e "$GITHUB_WORKSPACE/META6.json" ]; then - cd "$GITHUB_WORKSPACE" && zef install --deps-only --/test . + echo "${GITHUB_WORKSPACE}/META6.json" + if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then + cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test . fi # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "RAKU" "raku" "raku -I $GITHUB_WORKSPACE/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}" + LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILE_ARRAY_RAKU[@]}" fi ################ # PHP LINTING # ################ -if [ "$VALIDATE_PHP" == "true" ]; then +if [ "${VALIDATE_PHP}" == "true" ]; then ####################### # Lint the PHP files # ####################### @@ -1208,75 +1208,75 @@ fi ################ # RUBY LINTING # ################ -if [ "$VALIDATE_RUBY" == "true" ]; then +if [ "${VALIDATE_RUBY}" == "true" ]; then ####################### # Lint the ruby files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES --force-exclusion" ".*\.\(rb\)\$" "${FILE_ARRAY_RUBY[@]}" + LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" ".*\.\(rb\)\$" "${FILE_ARRAY_RUBY[@]}" fi ######################## # COFFEESCRIPT LINTING # ######################## -if [ "$VALIDATE_COFFEE" == "true" ]; then +if [ "${VALIDATE_COFFEE}" == "true" ]; then ######################### # Lint the coffee files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f $COFFEESCRIPT_LINTER_RULES" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}" + LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILE_ARRAY_COFFEESCRIPT[@]}" fi ################## # GOLANG LINTING # ################## -if [ "$VALIDATE_GO" == "true" ]; then +if [ "${VALIDATE_GO}" == "true" ]; then ######################### # Lint the golang files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "GO" "golangci-lint" "golangci-lint run -c $GO_LINTER_RULES" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}" + LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILE_ARRAY_GO[@]}" fi ##################### # TERRAFORM LINTING # ##################### -if [ "$VALIDATE_TERRAFORM" == "true" ]; then +if [ "${VALIDATE_TERRAFORM}" == "true" ]; then ############################ # Lint the Terraform files # ############################ # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}" + LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILE_ARRAY_TERRAFORM[@]}" fi ################### # ANSIBLE LINTING # ################### -if [ "$VALIDATE_ANSIBLE" == "true" ]; then +if [ "${VALIDATE_ANSIBLE}" == "true" ]; then ########################## # Lint the Ansible files # ########################## # Due to the nature of how we want to validate Ansible, we cannot use the # standard loop, since it looks for an ansible folder, excludes certain # files, and looks for additional changes, it should be an outlier - LintAnsibleFiles "$ANSIBLE_LINTER_RULES" # Passing rules but not needed, dont want to exclude unused var + LintAnsibleFiles "${ANSIBLE_LINTER_RULES}" # Passing rules but not needed, dont want to exclude unused var fi ###################### # JAVASCRIPT LINTING # ###################### -if [ "$VALIDATE_JAVASCRIPT_ES" == "true" ]; then +if [ "${VALIDATE_JAVASCRIPT_ES}" == "true" ]; then ############################# # Lint the Javascript files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" + LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_ES[@]}" fi ###################### # JAVASCRIPT LINTING # ###################### -if [ "$VALIDATE_JAVASCRIPT_STANDARD" == "true" ]; then +if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then ################################# # Get Javascript standard rules # ################################# @@ -1285,44 +1285,44 @@ if [ "$VALIDATE_JAVASCRIPT_STANDARD" == "true" ]; then # Lint the Javascript files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" + LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}" fi ###################### # JSX LINTING # ###################### -if [ "$VALIDATE_JSX" == "true" ]; then +if [ "${VALIDATE_JSX}" == "true" ]; then ############################# # Lint the JSX files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" + LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}" fi ###################### # TSX LINTING # ###################### -if [ "$VALIDATE_TSX" == "true" ]; then +if [ "${VALIDATE_TSX}" == "true" ]; then ############################# # Lint the TSX files # ############################# - LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" + LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}" fi ###################### # TYPESCRIPT LINTING # ###################### -if [ "$VALIDATE_TYPESCRIPT_ES" == "true" ]; then +if [ "${VALIDATE_TYPESCRIPT_ES}" == "true" ]; then ############################# # Lint the Typescript files # ############################# - LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" + LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_ES[@]}" fi ###################### # TYPESCRIPT LINTING # ###################### -if [ "$VALIDATE_TYPESCRIPT_STANDARD" == "true" ]; then +if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then ################################# # Get Typescript standard rules # ################################# @@ -1330,13 +1330,13 @@ if [ "$VALIDATE_TYPESCRIPT_STANDARD" == "true" ]; then ############################# # Lint the Typescript files # ############################# - LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" + LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}" fi ############### # CSS LINTING # ############### -if [ "$VALIDATE_CSS" == "true" ]; then +if [ "${VALIDATE_CSS}" == "true" ]; then ################################# # Get CSS standard rules # ################################# @@ -1344,13 +1344,13 @@ if [ "$VALIDATE_CSS" == "true" ]; then ############################# # Lint the CSS files # ############################# - LintCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}" + LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}" fi ############### # ENV LINTING # ############### -if [ "$VALIDATE_ENV" == "true" ]; then +if [ "${VALIDATE_ENV}" == "true" ]; then ####################### # Lint the env files # ####################### @@ -1361,7 +1361,7 @@ fi ################## # KOTLIN LINTING # ################## -if [ "$VALIDATE_KOTLIN" == "true" ]; then +if [ "${VALIDATE_KOTLIN}" == "true" ]; then ####################### # Lint the Kotlin files # ####################### @@ -1372,7 +1372,7 @@ fi ######################## # EDITORCONFIG LINTING # ######################## -if [ "$VALIDATE_EDITORCONFIG" == "true" ]; then +if [ "${VALIDATE_EDITORCONFIG}" == "true" ]; then #################################### # Lint the files with editorconfig # #################################### @@ -1383,30 +1383,30 @@ fi ################## # DART LINTING # ################## -if [ "$VALIDATE_DART" == "true" ]; then +if [ "${VALIDATE_DART}" == "true" ]; then ####################### # Lint the Dart files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "DART" "dart" "pub get || true && dartanalyzer --fatal-infos --fatal-warnings --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}" + LintCodebase "DART" "dart" "pub get || true && dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILE_ARRAY_DART[@]}" fi ################## # DOCKER LINTING # ################## -if [ "$VALIDATE_DOCKER" == "true" ]; then +if [ "${VALIDATE_DOCKER}" == "true" ]; then ######################### # Lint the docker files # ######################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" # NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file - LintCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c $(dirname $DOCKER_LINTER_RULES)" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" + LintCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKER_LINTER_RULES})" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}" fi ################### # CLOJURE LINTING # ################### -if [ "$VALIDATE_CLOJURE" == "true" ]; then +if [ "${VALIDATE_CLOJURE}" == "true" ]; then ################################# # Get Clojure standard rules # ################################# @@ -1414,24 +1414,24 @@ if [ "$VALIDATE_CLOJURE" == "true" ]; then ######################### # Lint the Clojure files # ######################### - LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}" + LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILE_ARRAY_CLOJURE[@]}" fi ################## # PROTOBUF LINTING # ################## -if [ "$VALIDATE_PROTOBUF" == "true" ]; then +if [ "${VALIDATE_PROTOBUF}" == "true" ]; then ####################### # Lint the Protocol Buffers files # ####################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path $PROTOBUF_LINTER_RULES" ".*\.\(proto\)\$" "${FILE_ARRAY_PROTOBUF[@]}" + LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "${FILE_ARRAY_PROTOBUF[@]}" fi ###################### # POWERSHELL LINTING # ###################### -if [ "$VALIDATE_POWERSHELL" == "true" ]; then +if [ "${VALIDATE_POWERSHELL}" == "true" ]; then ############################################################### # For POWERSHELL, ensure PSScriptAnalyzer module is available # ############################################################### @@ -1441,55 +1441,55 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ######################## # ARM Template LINTING # ######################## -if [ "$VALIDATE_ARM" == "true" ]; then +if [ "${VALIDATE_ARM}" == "true" ]; then ############################### # Lint the ARM Template files # ############################### # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "ARM" "arm-ttk" "Import-Module $ARM_TTK_PSD1 ; \$config = \$(Import-PowerShellDataFile -Path $ARM_LINTER_RULES) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "${FILE_ARRAY_ARM[@]}" + LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "${FILE_ARRAY_ARM[@]}" fi ################### # OPENAPI LINTING # ################### -if [ "$VALIDATE_OPENAPI" == "true" ]; then +if [ "${VALIDATE_OPENAPI}" == "true" ]; then # If we are validating all codebase we need to build file list because not every yml/json file is an OpenAPI file - if [ "$VALIDATE_ALL_CODEBASE" == "true" ]; then + if [ "${VALIDATE_ALL_CODEBASE}" == "true" ]; then ############################################################################### # Set the file seperator to newline to allow for grabbing objects with spaces # ############################################################################### IFS=$'\n' - mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE" -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 - FILE_ARRAY_OPENAPI+=("$FILE") + if DetectOpenAPIFile "${FILE}"; then + FILE_ARRAY_OPENAPI+=("${FILE}") fi done ########################### # Set IFS back to default # ########################### - IFS="$DEFAULT_IFS" + IFS="${DEFAULT_IFS}" fi ########################## # Lint the OpenAPI files # ########################## # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" "disabledfileext" "${FILE_ARRAY_OPENAPI[@]}" + LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "disabledfileext" "${FILE_ARRAY_OPENAPI[@]}" fi ################ # HTML LINTING # ################ -if [ "$VALIDATE_HTML" == "true" ]; then +if [ "${VALIDATE_HTML}" == "true" ]; then ################################# # Get HTML standard rules # ################################# @@ -1497,7 +1497,7 @@ if [ "$VALIDATE_HTML" == "true" ]; then ############################# # Lint the HTML files # ############################# - LintCodebase "HTML" "htmlhint" "htmlhint --config $HTML_LINTER_RULES" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}" + LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILE_ARRAY_HTML[@]}" fi ########## diff --git a/lib/validation.sh b/lib/validation.sh index 9be40a60..326a7a94 100755 --- a/lib/validation.sh +++ b/lib/validation.sh @@ -20,7 +20,7 @@ function GetValidationInfo() { ########################################### # Skip validation if were running locally # ########################################### - if [[ $RUN_LOCAL != "true" ]]; then + if [[ ${RUN_LOCAL} != "true" ]]; then ############################### # Convert string to lowercase # ############################### @@ -28,9 +28,9 @@ function GetValidationInfo() { ###################################### # Validate we should check all files # ###################################### - if [[ $VALIDATE_ALL_CODEBASE != "false" ]]; then + if [[ ${VALIDATE_ALL_CODEBASE} != "false" ]]; then # Set to true - VALIDATE_ALL_CODEBASE="$DEFAULT_VALIDATE_ALL_CODEBASE" + VALIDATE_ALL_CODEBASE="${DEFAULT_VALIDATE_ALL_CODEBASE}" echo "- Validating ALL files in code base..." else # Its false @@ -83,45 +83,45 @@ function GetValidationInfo() { # Determine if any linters were explicitly set # ################################################ ANY_SET="false" - if [[ -n $VALIDATE_YAML || -n \ - $VALIDATE_JSON || -n \ - $VALIDATE_XML || -n \ - $VALIDATE_MARKDOWN || -n \ - $VALIDATE_BASH || -n \ - $VALIDATE_PERL || -n \ - $VALIDATE_RAKU || -n \ - $VALIDATE_PHP || -n \ - $VALIDATE_PYTHON || -n \ - $VALIDATE_RUBY || -n \ - $VALIDATE_COFFEE || -n \ - $VALIDATE_ANSIBLE || -n \ - $VALIDATE_JAVASCRIPT_ES || -n \ - $VALIDATE_JAVASCRIPT_STANDARD || -n \ - $VALIDATE_TYPESCRIPT_ES || -n \ - $VALIDATE_TYPESCRIPT_STANDARD || -n \ - $VALIDATE_DOCKER || -n \ - $VALIDATE_GO || -n \ - $VALIDATE_TERRAFORM || -n \ - $VALIDATE_POWERSHELL || -n \ - $VALIDATE_ARM || -n \ - $VALIDATE_CSS || -n \ - $VALIDATE_ENV || -n \ - $VALIDATE_CLOJURE || -n \ - $VALIDATE_PROTOBUF || -n \ - $VALIDATE_OPENAPI || -n \ - $VALIDATE_KOTLIN || -n \ - $VALIDATE_DART || -n \ - $VALIDATE_EDITORCONFIG || -n \ - $VALIDATE_HTML ]]; then + if [[ -n ${VALIDATE_YAML} || -n \ + ${VALIDATE_JSON} || -n \ + ${VALIDATE_XML} || -n \ + ${VALIDATE_MARKDOWN} || -n \ + ${VALIDATE_BASH} || -n \ + ${VALIDATE_PERL} || -n \ + ${VALIDATE_RAKU} || -n \ + ${VALIDATE_PHP} || -n \ + ${VALIDATE_PYTHON} || -n \ + ${VALIDATE_RUBY} || -n \ + ${VALIDATE_COFFEE} || -n \ + ${VALIDATE_ANSIBLE} || -n \ + ${VALIDATE_JAVASCRIPT_ES} || -n \ + ${VALIDATE_JAVASCRIPT_STANDARD} || -n \ + ${VALIDATE_TYPESCRIPT_ES} || -n \ + ${VALIDATE_TYPESCRIPT_STANDARD} || -n \ + ${VALIDATE_DOCKER} || -n \ + ${VALIDATE_GO} || -n \ + ${VALIDATE_TERRAFORM} || -n \ + ${VALIDATE_POWERSHELL} || -n \ + ${VALIDATE_ARM} || -n \ + ${VALIDATE_CSS} || -n \ + ${VALIDATE_ENV} || -n \ + ${VALIDATE_CLOJURE} || -n \ + ${VALIDATE_PROTOBUF} || -n \ + ${VALIDATE_OPENAPI} || -n \ + ${VALIDATE_KOTLIN} || -n \ + ${VALIDATE_DART} || -n \ + ${VALIDATE_EDITORCONFIG} || -n \ + ${VALIDATE_HTML} ]]; then ANY_SET="true" fi #################################### # Validate if we should check YAML # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_YAML ]]; then + if [[ -z ${VALIDATE_YAML} ]]; then # YAML flag was not set - default to false VALIDATE_YAML="false" fi @@ -133,9 +133,9 @@ function GetValidationInfo() { #################################### # Validate if we should check JSON # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_JSON ]]; then + if [[ -z ${VALIDATE_JSON} ]]; then # JSON flag was not set - default to false VALIDATE_JSON="false" fi @@ -147,9 +147,9 @@ function GetValidationInfo() { ################################### # Validate if we should check XML # ################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_XML ]]; then + if [[ -z ${VALIDATE_XML} ]]; then # XML flag was not set - default to false VALIDATE_XML="false" fi @@ -161,9 +161,9 @@ function GetValidationInfo() { ######################################## # Validate if we should check MARKDOWN # ######################################## - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_MARKDOWN ]]; then + if [[ -z ${VALIDATE_MARKDOWN} ]]; then # MD flag was not set - default to false VALIDATE_MARKDOWN="false" fi @@ -175,9 +175,9 @@ function GetValidationInfo() { #################################### # Validate if we should check BASH # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_BASH ]]; then + if [[ -z ${VALIDATE_BASH} ]]; then # BASH flag was not set - default to false VALIDATE_BASH="false" fi @@ -189,9 +189,9 @@ function GetValidationInfo() { #################################### # Validate if we should check PERL # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_PERL ]]; then + if [[ -z ${VALIDATE_PERL} ]]; then # PERL flag was not set - default to false VALIDATE_PERL="false" fi @@ -203,9 +203,9 @@ function GetValidationInfo() { #################################### # Validate if we should check RAKU # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_RAKU ]]; then + if [[ -z ${VALIDATE_RAKU} ]]; then # RAKU flag was not set - default to false VALIDATE_RAKU="false" fi @@ -217,9 +217,9 @@ function GetValidationInfo() { #################################### # Validate if we should check PHP # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_PHP ]]; then + if [[ -z ${VALIDATE_PHP} ]]; then # PHP flag was not set - default to false VALIDATE_PHP="false" fi @@ -231,9 +231,9 @@ function GetValidationInfo() { ###################################### # Validate if we should check PYTHON # ###################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_PYTHON ]]; then + if [[ -z ${VALIDATE_PYTHON} ]]; then # PYTHON flag was not set - default to false VALIDATE_PYTHON="false" fi @@ -245,9 +245,9 @@ function GetValidationInfo() { #################################### # Validate if we should check RUBY # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_RUBY ]]; then + if [[ -z ${VALIDATE_RUBY} ]]; then # RUBY flag was not set - default to false VALIDATE_RUBY="false" fi @@ -259,9 +259,9 @@ function GetValidationInfo() { ###################################### # Validate if we should check COFFEE # ###################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_COFFEE ]]; then + if [[ -z ${VALIDATE_COFFEE} ]]; then # COFFEE flag was not set - default to false VALIDATE_COFFEE="false" fi @@ -273,9 +273,9 @@ function GetValidationInfo() { ####################################### # Validate if we should check ANSIBLE # ####################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_ANSIBLE ]]; then + if [[ -z ${VALIDATE_ANSIBLE} ]]; then # ANSIBLE flag was not set - default to false VALIDATE_ANSIBLE="false" fi @@ -287,9 +287,9 @@ function GetValidationInfo() { ############################################# # Validate if we should check JAVASCRIPT_ES # ############################################# - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_JAVASCRIPT_ES ]]; then + if [[ -z ${VALIDATE_JAVASCRIPT_ES} ]]; then # JAVASCRIPT_ES flag was not set - default to false VALIDATE_JAVASCRIPT_ES="false" fi @@ -301,9 +301,9 @@ function GetValidationInfo() { ################################################### # Validate if we should check JAVASCRIPT_STANDARD # ################################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_JAVASCRIPT_STANDARD ]]; then + if [[ -z ${VALIDATE_JAVASCRIPT_STANDARD} ]]; then # JAVASCRIPT_STANDARD flag was not set - default to false VALIDATE_JAVASCRIPT_STANDARD="false" fi @@ -315,9 +315,9 @@ function GetValidationInfo() { ############################################# # Validate if we should check JSX # ############################################# - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_JSX ]]; then + if [[ -z ${VALIDATE_JSX} ]]; then # JSX flag was not set - default to false VALIDATE_JSX="false" fi @@ -329,9 +329,9 @@ function GetValidationInfo() { ############################################# # Validate if we should check TSX # ############################################# - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_TSX ]]; then + if [[ -z ${VALIDATE_TSX} ]]; then # TSX flag was not set - default to false VALIDATE_TSX="false" fi @@ -343,9 +343,9 @@ function GetValidationInfo() { ############################################# # Validate if we should check TYPESCRIPT_ES # ############################################# - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_TYPESCRIPT_ES ]]; then + if [[ -z ${VALIDATE_TYPESCRIPT_ES} ]]; then # TYPESCRIPT_ES flag was not set - default to false VALIDATE_TYPESCRIPT_ES="false" fi @@ -357,9 +357,9 @@ function GetValidationInfo() { ################################################### # Validate if we should check TYPESCRIPT_STANDARD # ################################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_TYPESCRIPT_STANDARD ]]; then + if [[ -z ${VALIDATE_TYPESCRIPT_STANDARD} ]]; then # TYPESCRIPT_STANDARD flag was not set - default to false VALIDATE_TYPESCRIPT_STANDARD="false" fi @@ -371,9 +371,9 @@ function GetValidationInfo() { ###################################### # Validate if we should check DOCKER # ###################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_DOCKER ]]; then + if [[ -z ${VALIDATE_DOCKER} ]]; then # DOCKER flag was not set - default to false VALIDATE_DOCKER="false" fi @@ -385,9 +385,9 @@ function GetValidationInfo() { ################################## # Validate if we should check GO # ################################## - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_GO ]]; then + if [[ -z ${VALIDATE_GO} ]]; then # GO flag was not set - default to false VALIDATE_GO="false" fi @@ -399,9 +399,9 @@ function GetValidationInfo() { ######################################### # Validate if we should check TERRAFORM # ######################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_TERRAFORM ]]; then + if [[ -z ${VALIDATE_TERRAFORM} ]]; then # TERRAFORM flag was not set - default to false VALIDATE_TERRAFORM="false" fi @@ -413,9 +413,9 @@ function GetValidationInfo() { ######################################### # Validate if we should check POWERSHELL # ######################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_POWERSHELL ]]; then + if [[ -z ${VALIDATE_POWERSHELL} ]]; then # POWERSHELL flag was not set - default to false VALIDATE_POWERSHELL="false" fi @@ -427,9 +427,9 @@ function GetValidationInfo() { ################################### # Validate if we should check ARM # ################################### - if [[ "$ANY_SET" == "true" ]]; then + if [[ "${ANY_SET}" == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z "$VALIDATE_ARM" ]]; then + if [[ -z "${VALIDATE_ARM}" ]]; then # ARM flag was not set - default to false VALIDATE_ARM="false" fi @@ -441,9 +441,9 @@ function GetValidationInfo() { ################################### # Validate if we should check CSS # ################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_CSS ]]; then + if [[ -z ${VALIDATE_CSS} ]]; then # CSS flag was not set - default to false VALIDATE_CSS="false" fi @@ -455,9 +455,9 @@ function GetValidationInfo() { ################################### # Validate if we should check ENV # ################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_ENV ]]; then + if [[ -z ${VALIDATE_ENV} ]]; then # ENV flag was not set - default to false VALIDATE_ENV="false" fi @@ -469,9 +469,9 @@ function GetValidationInfo() { ###################################### # Validate if we should check KOTLIN # ###################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_KOTLIN ]]; then + if [[ -z ${VALIDATE_KOTLIN} ]]; then # ENV flag was not set - default to false VALIDATE_KOTLIN="false" fi @@ -483,9 +483,9 @@ function GetValidationInfo() { #################################### # Validate if we should check DART # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_DART ]]; then + if [[ -z ${VALIDATE_DART} ]]; then # ENV flag was not set - default to false VALIDATE_DART="false" fi @@ -497,9 +497,9 @@ function GetValidationInfo() { ####################################### # Validate if we should check OPENAPI # ####################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_OPENAPI ]]; then + if [[ -z ${VALIDATE_OPENAPI} ]]; then # OPENAPI flag was not set - default to false VALIDATE_OPENAPI="false" fi @@ -511,9 +511,9 @@ function GetValidationInfo() { ####################################### # Validate if we should check PROTOBUF # ####################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_PROTOBUF ]]; then + if [[ -z ${VALIDATE_PROTOBUF} ]]; then # PROTOBUF flag was not set - default to false VALIDATE_PROTOBUF="false" fi @@ -525,9 +525,9 @@ function GetValidationInfo() { ####################################### # Validate if we should check Clojure # ####################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_CLOJURE ]]; then + if [[ -z ${VALIDATE_CLOJURE} ]]; then # Clojure flag was not set - default to false VALIDATE_CLOJURE="false" fi @@ -539,16 +539,16 @@ function GetValidationInfo() { ############################################ # Validate if we should check editorconfig # ############################################ - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_EDITORCONFIG ]]; then + if [[ -z ${VALIDATE_EDITORCONFIG} ]]; then # EDITORCONFIG flag was not set - default to false VALIDATE_EDITORCONFIG="false" fi else # No linter flags were set # special case checking for .editorconfig - if [ -f "$GITHUB_WORKSPACE/.editorconfig" ]; then + if [ -f "${GITHUB_WORKSPACE}/.editorconfig" ]; then VALIDATE_EDITORCONFIG="true" fi fi @@ -556,9 +556,9 @@ function GetValidationInfo() { #################################### # Validate if we should check HTML # #################################### - if [[ $ANY_SET == "true" ]]; then + if [[ ${ANY_SET} == "true" ]]; then # Some linter flags were set - only run those set to true - if [[ -z $VALIDATE_HTML ]]; then + if [[ -z ${VALIDATE_HTML} ]]; then # HTML flag was not set - default to false VALIDATE_HTML="false" fi @@ -570,152 +570,152 @@ function GetValidationInfo() { ####################################### # Print which linters we are enabling # ####################################### - if [[ $VALIDATE_YAML == "true" ]]; then + if [[ ${VALIDATE_YAML} == "true" ]]; then PRINT_ARRAY+=("- Validating [YAML] files in code base...") else PRINT_ARRAY+=("- Excluding [YAML] files in code base...") fi - if [[ $VALIDATE_JSON == "true" ]]; then + if [[ ${VALIDATE_JSON} == "true" ]]; then PRINT_ARRAY+=("- Validating [JSON] files in code base...") else PRINT_ARRAY+=("- Excluding [JSON] files in code base...") fi - if [[ $VALIDATE_XML == "true" ]]; then + if [[ ${VALIDATE_XML} == "true" ]]; then PRINT_ARRAY+=("- Validating [XML] files in code base...") else PRINT_ARRAY+=("- Excluding [XML] files in code base...") fi - if [[ $VALIDATE_MARKDOWN == "true" ]]; then + if [[ ${VALIDATE_MARKDOWN} == "true" ]]; then PRINT_ARRAY+=("- Validating [MARKDOWN] files in code base...") else PRINT_ARRAY+=("- Excluding [MARKDOWN] files in code base...") fi - if [[ $VALIDATE_BASH == "true" ]]; then + if [[ ${VALIDATE_BASH} == "true" ]]; then PRINT_ARRAY+=("- Validating [BASH] files in code base...") else PRINT_ARRAY+=("- Excluding [BASH] files in code base...") fi - if [[ $VALIDATE_PERL == "true" ]]; then + if [[ ${VALIDATE_PERL} == "true" ]]; then PRINT_ARRAY+=("- Validating [PERL] files in code base...") else PRINT_ARRAY+=("- Excluding [PERL] files in code base...") fi - if [[ $VALIDATE_RAKU == "true" ]]; then + if [[ ${VALIDATE_RAKU} == "true" ]]; then PRINT_ARRAY+=("- Validating [RAKU] files in code base...") else PRINT_ARRAY+=("- Excluding [RAKU] files in code base...") fi - if [[ $VALIDATE_PHP == "true" ]]; then + if [[ ${VALIDATE_PHP} == "true" ]]; then PRINT_ARRAY+=("- Validating [PHP] files in code base...") else PRINT_ARRAY+=("- Excluding [PHP] files in code base...") fi - if [[ $VALIDATE_PYTHON == "true" ]]; then + if [[ ${VALIDATE_PYTHON} == "true" ]]; then PRINT_ARRAY+=("- Validating [PYTHON] files in code base...") else PRINT_ARRAY+=("- Excluding [PYTHON] files in code base...") fi - if [[ $VALIDATE_RUBY == "true" ]]; then + if [[ ${VALIDATE_RUBY} == "true" ]]; then PRINT_ARRAY+=("- Validating [RUBY] files in code base...") else PRINT_ARRAY+=("- Excluding [RUBY] files in code base...") fi - if [[ $VALIDATE_COFFEE == "true" ]]; then + if [[ ${VALIDATE_COFFEE} == "true" ]]; then PRINT_ARRAY+=("- Validating [COFFEE] files in code base...") else PRINT_ARRAY+=("- Excluding [COFFEE] files in code base...") fi - if [[ $VALIDATE_ANSIBLE == "true" ]]; then + if [[ ${VALIDATE_ANSIBLE} == "true" ]]; then PRINT_ARRAY+=("- Validating [ANSIBLE] files in code base...") else PRINT_ARRAY+=("- Excluding [ANSIBLE] files in code base...") fi - if [[ $VALIDATE_JAVASCRIPT_ES == "true" ]]; then + if [[ ${VALIDATE_JAVASCRIPT_ES} == "true" ]]; then PRINT_ARRAY+=("- Validating [JAVASCRIPT(eslint)] files in code base...") else PRINT_ARRAY+=("- Excluding [JAVASCRIPT(eslint)] files in code base...") fi - if [[ $VALIDATE_JAVASCRIPT_STANDARD == "true" ]]; then + if [[ ${VALIDATE_JAVASCRIPT_STANDARD} == "true" ]]; then PRINT_ARRAY+=("- Validating [JAVASCRIPT(standard)] files in code base...") else PRINT_ARRAY+=("- Excluding [JAVASCRIPT(standard)] files in code base...") fi - if [[ $VALIDATE_TYPESCRIPT_ES == "true" ]]; then + if [[ ${VALIDATE_TYPESCRIPT_ES} == "true" ]]; then PRINT_ARRAY+=("- Validating [TYPESCRIPT(eslint)] files in code base...") else PRINT_ARRAY+=("- Excluding [TYPESCRIPT(eslint)] files in code base...") fi - if [[ $VALIDATE_TYPESCRIPT_STANDARD == "true" ]]; then + if [[ ${VALIDATE_TYPESCRIPT_STANDARD} == "true" ]]; then PRINT_ARRAY+=("- Validating [TYPESCRIPT(standard)] files in code base...") else PRINT_ARRAY+=("- Excluding [TYPESCRIPT(standard)] files in code base...") fi - if [[ $VALIDATE_DOCKER == "true" ]]; then + if [[ ${VALIDATE_DOCKER} == "true" ]]; then PRINT_ARRAY+=("- Validating [DOCKER] files in code base...") else PRINT_ARRAY+=("- Excluding [DOCKER] files in code base...") fi - if [[ $VALIDATE_GO == "true" ]]; then + if [[ ${VALIDATE_GO} == "true" ]]; then PRINT_ARRAY+=("- Validating [GOLANG] files in code base...") else PRINT_ARRAY+=("- Excluding [GOLANG] files in code base...") fi - if [[ $VALIDATE_TERRAFORM == "true" ]]; then + if [[ ${VALIDATE_TERRAFORM} == "true" ]]; then PRINT_ARRAY+=("- Validating [TERRAFORM] files in code base...") else PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...") fi - if [[ $VALIDATE_POWERSHELL == "true" ]]; then + if [[ ${VALIDATE_POWERSHELL} == "true" ]]; then PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...") else PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...") fi - if [[ $VALIDATE_ARM == "true" ]]; then + if [[ ${VALIDATE_ARM} == "true" ]]; then PRINT_ARRAY+=("- Validating [ARM] files in code base...") else PRINT_ARRAY+=("- Excluding [ARM] files in code base...") fi - if [[ $VALIDATE_CSS == "true" ]]; then + if [[ ${VALIDATE_CSS} == "true" ]]; then PRINT_ARRAY+=("- Validating [CSS] files in code base...") else PRINT_ARRAY+=("- Excluding [CSS] files in code base...") fi - if [[ $VALIDATE_CLOJURE == "true" ]]; then + if [[ ${VALIDATE_CLOJURE} == "true" ]]; then PRINT_ARRAY+=("- Validating [CLOJURE] files in code base...") else PRINT_ARRAY+=("- Excluding [CLOJURE] files in code base...") fi - if [[ $VALIDATE_ENV == "true" ]]; then + if [[ ${VALIDATE_ENV} == "true" ]]; then PRINT_ARRAY+=("- Validating [ENV] files in code base...") else PRINT_ARRAY+=("- Excluding [ENV] files in code base...") fi - if [[ $VALIDATE_KOTLIN == "true" ]]; then + if [[ ${VALIDATE_KOTLIN} == "true" ]]; then PRINT_ARRAY+=("- Validating [KOTLIN] files in code base...") else PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...") fi - if [[ $VALIDATE_OPENAPI == "true" ]]; then + if [[ ${VALIDATE_OPENAPI} == "true" ]]; then PRINT_ARRAY+=("- Validating [OPENAPI] files in code base...") else PRINT_ARRAY+=("- Excluding [OPENAPI] files in code base...") fi - if [[ $VALIDATE_PROTOBUF == "true" ]]; then + if [[ ${VALIDATE_PROTOBUF} == "true" ]]; then PRINT_ARRAY+=("- Validating [PROTOBUF] files in code base...") else PRINT_ARRAY+=("- Excluding [PROTOBUF] files in code base...") fi - if [[ $VALIDATE_DART == "true" ]]; then + if [[ ${VALIDATE_DART} == "true" ]]; then PRINT_ARRAY+=("- Validating [DART] files in code base...") else PRINT_ARRAY+=("- Excluding [DART] files in code base...") fi - if [[ $VALIDATE_EDITORCONFIG == "true" ]]; then + if [[ ${VALIDATE_EDITORCONFIG} == "true" ]]; then PRINT_ARRAY+=("- Validating [EDITORCONFIG] files in code base...") else PRINT_ARRAY+=("- Excluding [EDITORCONFIG] files in code base...") fi - if [[ $VALIDATE_HTML == "true" ]]; then + if [[ ${VALIDATE_HTML} == "true" ]]; then PRINT_ARRAY+=("- Validating [HTML] files in code base...") else PRINT_ARRAY+=("- Excluding [HTML] files in code base...") @@ -724,9 +724,9 @@ function GetValidationInfo() { ############################## # Validate Ansible Directory # ############################## - if [ -z "$ANSIBLE_DIRECTORY" ]; then + if [ -z "${ANSIBLE_DIRECTORY}" ]; then # No Value, need to default - ANSIBLE_DIRECTORY="$DEFAULT_ANSIBLE_DIRECTORY" + ANSIBLE_DIRECTORY="${DEFAULT_ANSIBLE_DIRECTORY}" else # Check if first char is '/' if [[ ${ANSIBLE_DIRECTORY:0:1} == "/" ]]; then @@ -734,19 +734,19 @@ function GetValidationInfo() { ANSIBLE_DIRECTORY="${ANSIBLE_DIRECTORY:1}" fi # Need to give it full path - TEMP_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/$ANSIBLE_DIRECTORY" + TEMP_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/${ANSIBLE_DIRECTORY}" # Set the value - ANSIBLE_DIRECTORY="$TEMP_ANSIBLE_DIRECTORY" + ANSIBLE_DIRECTORY="${TEMP_ANSIBLE_DIRECTORY}" fi ############################### # Get the disable errors flag # ############################### - if [ -z "$DISABLE_ERRORS" ]; then + if [ -z "${DISABLE_ERRORS}" ]; then ################################## # No flag passed, set to default # ################################## - DISABLE_ERRORS="$DEFAULT_DISABLE_ERRORS" + DISABLE_ERRORS="${DEFAULT_DISABLE_ERRORS}" fi ############################### @@ -757,18 +757,18 @@ function GetValidationInfo() { ############################ # Set to false if not true # ############################ - if [ "$DISABLE_ERRORS" != "true" ]; then + if [ "${DISABLE_ERRORS}" != "true" ]; then DISABLE_ERRORS="false" fi ############################ # Get the run verbose flag # ############################ - if [ -z "$ACTIONS_RUNNER_DEBUG" ]; then + if [ -z "${ACTIONS_RUNNER_DEBUG}" ]; then ################################## # No flag passed, set to default # ################################## - ACTIONS_RUNNER_DEBUG="$DEFAULT_ACTIONS_RUNNER_DEBUG" + ACTIONS_RUNNER_DEBUG="${DEFAULT_ACTIONS_RUNNER_DEBUG}" fi ############################### @@ -779,25 +779,25 @@ function GetValidationInfo() { ############################ # Set to true if not false # ############################ - if [ "$ACTIONS_RUNNER_DEBUG" != "false" ]; then + if [ "${ACTIONS_RUNNER_DEBUG}" != "false" ]; then ACTIONS_RUNNER_DEBUG="true" fi ################### # Debug on runner # ################### - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then ########################### # Print the validate info # ########################### for LINE in "${PRINT_ARRAY[@]}"; do - echo "$LINE" + echo "${LINE}" done echo "--- DEBUG INFO ---" echo "---------------------------------------------" RUNNER=$(whoami) - echo "Runner:[$RUNNER]" + echo "Runner:[${RUNNER}]" echo "ENV:" printenv echo "---------------------------------------------" diff --git a/lib/worker.sh b/lib/worker.sh index 17db091c..4662b7dd 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -13,11 +13,11 @@ function LintCodebase() { #################### # Pull in the vars # #################### - FILE_TYPE="$1" && shift # Pull the variable and remove from array path (Example: JSON) - LINTER_NAME="$1" && shift # Pull the variable and remove from array path (Example: jsonlint) - LINTER_COMMAND="$1" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) - FILE_EXTENSIONS="$1" && shift # Pull the variable and remove from array path (Example: *.json) - FILE_ARRAY=("$@") # Array of files to validate (Example: $FILE_ARRAY_JSON) + FILE_TYPE="${1}" && shift # Pull the variable and remove from array path (Example: JSON) + LINTER_NAME="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint) + LINTER_COMMAND="${1}" && shift # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) + FILE_EXTENSIONS="${1}" && shift # Pull the variable and remove from array path (Example: *.json) + FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON}) ###################### # Create Print Array # @@ -30,14 +30,14 @@ function LintCodebase() { PRINT_ARRAY+=("") PRINT_ARRAY+=("----------------------------------------------") PRINT_ARRAY+=("----------------------------------------------") - PRINT_ARRAY+=("Linting [$FILE_TYPE] files...") + PRINT_ARRAY+=("Linting [${FILE_TYPE}] files...") PRINT_ARRAY+=("----------------------------------------------") PRINT_ARRAY+=("----------------------------------------------") ##################################### # Validate we have linter installed # ##################################### - VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1) + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) ####################### # Load the error code # @@ -47,15 +47,15 @@ function LintCodebase() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}" exit 1 else # Success - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then - echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[$LINTER_NAME]${F[B]} in system location: ${F[W]}[$VALIDATE_INSTALL_CMD]${NC}" + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then + echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" fi fi @@ -72,10 +72,10 @@ function LintCodebase() { ############################################################ # Check to see if we need to go through array or all files # ############################################################ - if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "$VALIDATE_ALL_CODEBASE" == "false" ]; then + if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then # No files found in commit and user has asked to not validate code base SKIP_FLAG=1 - # echo " - No files found in changeset to lint for language:[$FILE_TYPE]" + # echo " - No files found in changeset to lint for language:[${FILE_TYPE}]" elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then # We have files added to array of files to check LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list @@ -88,12 +88,12 @@ function LintCodebase() { ################################# # Get list of all files to lint # ################################# - mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE" -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 # ########################### - IFS="$DEFAULT_IFS" + IFS="${DEFAULT_IFS}" ############################################################ # Set it back to empty if loaded with blanks from scanning # @@ -113,7 +113,7 @@ function LintCodebase() { ############################### # Check if any data was found # ############################### - if [ $SKIP_FLAG -eq 0 ]; then + if [ ${SKIP_FLAG} -eq 0 ]; then ###################### # Print Header array # ###################### @@ -121,7 +121,7 @@ function LintCodebase() { ######################### # Print the header info # ######################### - echo "$LINE" + echo "${LINE}" done ######################################## @@ -141,18 +141,18 @@ function LintCodebase() { ##################### # Get the file name # ##################### - FILE_NAME=$(basename "$FILE" 2>&1) + FILE_NAME=$(basename "${FILE}" 2>&1) ##################################################### # Make sure we dont lint node modules or test cases # ##################################################### - if [[ $FILE == *"node_modules"* ]]; then + if [[ ${FILE} == *"node_modules"* ]]; then # This is a node modules file continue - elif [[ $FILE == *"$TEST_CASE_FOLDER"* ]]; then + elif [[ ${FILE} == *"${TEST_CASE_FOLDER}"* ]]; then # This is the test cases, we should always skip continue - elif [[ $FILE == *".git"* ]]; then + elif [[ ${FILE} == *".git"* ]]; then # This is likely the .git folder and shouldnt be parsed continue fi @@ -166,12 +166,12 @@ function LintCodebase() { # File print # ############## echo "---------------------------" - echo "File:[$FILE]" + echo "File:[${FILE}]" ################################# # Add the language to the array # ################################# - LINTED_LANGUAGES_ARRAY+=("$FILE_TYPE") + LINTED_LANGUAGES_ARRAY+=("${FILE_TYPE}") #################### # Set the base Var # @@ -183,14 +183,14 @@ function LintCodebase() { # - PowerShell (PSScriptAnalyzer) # # - ARM (arm-ttk) # #################################### - if [[ $FILE_TYPE == "POWERSHELL" ]] || [[ $FILE_TYPE == "ARM" ]]; then + if [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then ################################ # Lint the file with the rules # ################################ # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell LINT_CMD=$( - cd "$GITHUB_WORKSPACE" || exit - pwsh -NoProfile -NoLogo -Command "$LINTER_COMMAND $FILE; if (\$Error.Count) { exit 1 }" + cd "${GITHUB_WORKSPACE}" || exit + pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 1 }" exit $? 2>&1 ) else @@ -198,8 +198,8 @@ function LintCodebase() { # Lint the file with the rules # ################################ LINT_CMD=$( - cd "$GITHUB_WORKSPACE" || exit - $LINTER_COMMAND "$FILE" 2>&1 + cd "${GITHUB_WORKSPACE}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 ) fi @@ -211,27 +211,27 @@ function LintCodebase() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" # Increment the error count - (("ERRORS_FOUND_$FILE_TYPE++")) + (("ERRORS_FOUND_${FILE_TYPE}++")) ####################################################### # Store the linting as a temporary file in TAP format # ####################################################### if IsTAP ; then NotOkTap "${INDEX}" "${FILE}" "${TMPFILE}" - AddDetailedMessageIfEnabled "$LINT_CMD" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" fi else ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}" + echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" ####################################################### # Store the linting as a temporary file in TAP format # @@ -257,11 +257,11 @@ function TestCodebase() { #################### # Pull in the vars # #################### - FILE_TYPE="$1" # Pull the variable and remove from array path (Example: JSON) - LINTER_NAME="$2" # Pull the variable and remove from array path (Example: jsonlint) - LINTER_COMMAND="$3" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) - FILE_EXTENSIONS="$4" # Pull the variable and remove from array path (Example: *.json) - INDVIDUAL_TEST_FOLDER="$5" # Folder for specific tests + FILE_TYPE="${1}" # Pull the variable and remove from array path (Example: JSON) + LINTER_NAME="${2}" # Pull the variable and remove from array path (Example: jsonlint) + LINTER_COMMAND="${3}" # Pull the variable and remove from array path (Example: jsonlint -c ConfigFile /path/to/file) + FILE_EXTENSIONS="${4}" # Pull the variable and remove from array path (Example: *.json) + INDVIDUAL_TEST_FOLDER="${5}" # Folder for specific tests TESTS_RAN=0 # Incremented when tests are ran, this will help find failed finds ################ @@ -270,7 +270,7 @@ function TestCodebase() { echo "" echo "----------------------------------------------" echo "----------------------------------------------" - echo "Testing Codebase [$FILE_TYPE] files..." + echo "Testing Codebase [${FILE_TYPE}] files..." echo "----------------------------------------------" echo "----------------------------------------------" echo "" @@ -278,7 +278,7 @@ function TestCodebase() { ##################################### # Validate we have linter installed # ##################################### - VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1) + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) ####################### # Load the error code # @@ -288,14 +288,14 @@ function TestCodebase() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [$LINTER_NAME] in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find [${LINTER_NAME}] in system!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}" exit 1 else # Success - echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[$LINTER_NAME]${F[B]} in system location: ${F[W]}[$VALIDATE_INSTALL_CMD]${NC}" + echo -e "${NC}${F[B]}Successfully found binary for ${F[W]}[${LINTER_NAME}]${F[B]} in system location: ${F[W]}[${VALIDATE_INSTALL_CMD}]${NC}" fi ########################## @@ -306,7 +306,7 @@ function TestCodebase() { ################################# # Get list of all files to lint # ################################# - mapfile -t LIST_FILES < <(find "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$INDVIDUAL_TEST_FOLDER" -type f -regex "$FILE_EXTENSIONS" ! -path "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/ansible/ghe-initialize/*" | sort 2>&1) + mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" -type f -regex "${FILE_EXTENSIONS}" ! -path "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/ansible/ghe-initialize/*" | sort 2>&1) ######################################## # Prepare context if TAP output format # @@ -324,18 +324,18 @@ function TestCodebase() { ##################### # Get the file name # ##################### - FILE_NAME=$(basename "$FILE" 2>&1) + FILE_NAME=$(basename "${FILE}" 2>&1) ############################ # Get the file pass status # ############################ # Example: markdown_good_1.md -> good - FILE_STATUS=$(echo "$FILE_NAME" | cut -f2 -d'_') + FILE_STATUS=$(echo "${FILE_NAME}" | cut -f2 -d'_') ######################################################### # If not found, assume it should be linted successfully # ######################################################### - if [ -z "$FILE_STATUS" ] || [[ $FILE == *"README"* ]]; then + if [ -z "${FILE_STATUS}" ] || [[ ${FILE} == *"README"* ]]; then ################################## # Set to good for proper linting # ################################## @@ -346,7 +346,7 @@ function TestCodebase() { # File print # ############## echo "---------------------------" - echo "File:[$FILE]" + echo "File:[${FILE}]" ######################## # Set the lint command # @@ -356,8 +356,8 @@ function TestCodebase() { ####################################### # Check if docker and get folder name # ####################################### - if [[ $FILE_TYPE == "DOCKER" ]]; then - if [[ $FILE == *"good"* ]]; then + if [[ ${FILE_TYPE} == "DOCKER" ]]; then + if [[ ${FILE} == *"good"* ]]; then ############# # Good file # ############# @@ -373,11 +373,11 @@ function TestCodebase() { ##################### # Check for ansible # ##################### - if [[ $FILE_TYPE == "ANSIBLE" ]]; then + if [[ ${FILE_TYPE} == "ANSIBLE" ]]; then ######################################## # Make sure we dont lint certain files # ######################################## - if [[ $FILE == *"vault.yml"* ]] || [[ $FILE == *"galaxy.yml"* ]]; then + if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then # This is a file we dont look at continue fi @@ -386,17 +386,17 @@ function TestCodebase() { # Lint the file with the rules # ################################ LINT_CMD=$( - cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$INDVIDUAL_TEST_FOLDER" || exit - $LINTER_COMMAND "$FILE" 2>&1 + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 ) - elif [[ $FILE_TYPE == "POWERSHELL" ]] || [[ $FILE_TYPE == "ARM" ]]; then + elif [[ ${FILE_TYPE} == "POWERSHELL" ]] || [[ ${FILE_TYPE} == "ARM" ]]; then ################################ # Lint the file with the rules # ################################ # Need to run PowerShell commands using pwsh -c, also exit with exit code from inner subshell LINT_CMD=$( - cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit - pwsh -NoProfile -NoLogo -Command "$LINTER_COMMAND $FILE; if (\$Error.Count) { exit 1 }" + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit + pwsh -NoProfile -NoLogo -Command "${LINTER_COMMAND} ${FILE}; if (\${Error}.Count) { exit 1 }" exit $? 2>&1 ) else @@ -404,8 +404,8 @@ function TestCodebase() { # Lint the file with the rules # ################################ LINT_CMD=$( - cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit - $LINTER_COMMAND "$FILE" 2>&1 + cd "${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}" || exit + ${LINTER_COMMAND} "${FILE}" 2>&1 ) fi @@ -422,24 +422,24 @@ function TestCodebase() { ######################################## # Check for if it was supposed to pass # ######################################## - if [[ $FILE_STATUS == "good" ]]; then + if [[ ${FILE_STATUS} == "good" ]]; then ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count - (("ERRORS_FOUND_$FILE_TYPE++")) + (("ERRORS_FOUND_${FILE_TYPE}++")) else ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}" + echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" fi ####################################################### # Store the linting as a temporary file in TAP format # @@ -454,28 +454,28 @@ function TestCodebase() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -eq 0 ]; then + if [ ${ERROR_CODE} -eq 0 ]; then ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} This file should have failed test case!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[$LINTER_COMMAND $FILE]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC} Linter CMD:[${LINTER_COMMAND} ${FILE}]${NC}" # Increment the error count - (("ERRORS_FOUND_$FILE_TYPE++")) + (("ERRORS_FOUND_${FILE_TYPE}++")) else ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} failed test case with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}" + echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} failed test case with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" fi ####################################################### # Store the linting as a temporary file in TAP format # ####################################################### if IsTAP ; then NotOkTap "${TESTS_RAN}" "${FILE_NAME}" "${TMPFILE}" - AddDetailedMessageIfEnabled "$LINT_CMD" "${TMPFILE}" + AddDetailedMessageIfEnabled "${LINT_CMD}" "${TMPFILE}" fi fi done @@ -490,24 +490,24 @@ function TestCodebase() { ######################################################################## # If expected TAP report exists then compare with the generated report # ######################################################################## - EXPECTED_FILE="$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/$INDVIDUAL_TEST_FOLDER/reports/expected-${FILE_TYPE}.tap" - if [ -e "$EXPECTED_FILE" ] ; then + EXPECTED_FILE="${GITHUB_WORKSPACE}/${TEST_CASE_FOLDER}/${INDVIDUAL_TEST_FOLDER}/reports/expected-${FILE_TYPE}.tap" + if [ -e "${EXPECTED_FILE}" ] ; then TMPFILE=$(mktemp -q "/tmp/diff-${FILE_TYPE}.XXXXXX") ## Ignore white spaces, case sensitive if ! diff -a -w -i "${EXPECTED_FILE}" "${REPORT_OUTPUT_FILE}" > "${TMPFILE}" 2>&1; then ############################################# # We failed to compare the reporting output # ############################################# - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to assert TAP output:[$LINTER_NAME]${NC}"! + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to assert TAP output:[${LINTER_NAME}]${NC}"! echo "Please validate the asserts!" cat "${TMPFILE}" exit 1 else # Success - echo -e "${NC}${F[B]}Successfully validation in the expected TAP format for ${F[W]}[$LINTER_NAME]${NC}" + echo -e "${NC}${F[B]}Successfully validation in the expected TAP format for ${F[W]}[${LINTER_NAME}]${NC}" fi else - echo -e "${NC}${F[Y]}WARN!${NC} No TAP expected file found at:[$EXPECTED_FILE]${NC}" + echo -e "${NC}${F[Y]}WARN!${NC} No TAP expected file found at:[${EXPECTED_FILE}]${NC}" echo "skipping report assertions" ##################################### # Append the file type to the array # @@ -519,11 +519,11 @@ function TestCodebase() { ############################## # Validate we ran some tests # ############################## - if [ "$TESTS_RAN" -eq 0 ]; then + if [ "${TESTS_RAN}" -eq 0 ]; then ################################################# # We failed to find files and no tests were ran # ################################################# - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[$LINTER_NAME]${NC}"! + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find any tests ran for the Linter:[${LINTER_NAME}]${NC}"! echo "Please validate logic or that tests exist!" exit 1 fi @@ -552,37 +552,37 @@ function RunTestCases() { # Test case languages # ####################### # TestCodebase "Language" "Linter" "Linter-command" "Regex to find files" "Test Folder" - TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" ".*\.\(yml\|yaml\)\$" "ansible" - TestCodebase "ARM" "arm-ttk" "Import-Module $ARM_TTK_PSD1 ; \$config = \$(Import-PowerShellDataFile -Path $ARM_LINTER_RULES) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" + TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible" + TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm" TestCodebase "BASH" "shellcheck" "shellcheck --color" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell" - TestCodebase "CFN" "cfn-lint" "cfn-lint --config-file $CFN_LINTER_RULES" ".*\.\(json\|yml\|yaml\)\$" "cfn" - TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config $CLOJURE_LINTER_RULES --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" - TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f $COFFEESCRIPT_LINTER_RULES" ".*\.\(coffee\)\$" "coffeescript" - TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" "css" - TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options $DART_LINTER_RULES" ".*\.\(dart\)\$" "dart" - TestCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" "docker" + TestCodebase "CFN" "cfn-lint" "cfn-lint --config-file ${CFN_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cfn" + TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure" + TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript" + TestCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\)\$" "css" + TestCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "dart" + TestCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c ${DOCKER_LINTER_RULES}" ".*\(Dockerfile\)\$" "docker" TestCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" ".*\.ext$" "editorconfig-checker" TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "env" - TestCodebase "GO" "golangci-lint" "golangci-lint run -c $GO_LINTER_RULES" ".*\.\(go\)\$" "golang" - TestCodebase "HTML" "htmlhint" "htmlhint --config $HTML_LINTER_RULES" ".*\.\(html\)\$" "html" - TestCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(js\)\$" "javascript" - TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" "javascript" + TestCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "golang" + TestCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "html" + TestCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "javascript" + TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "javascript" TestCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "json" TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "kotlin" - TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c $MARKDOWN_LINTER_RULES" ".*\.\(md\)\$" "markdown" + TestCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "markdown" TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "perl" TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "php" - TestCodebase "OPENAPI" "spectral" "spectral lint -r $OPENAPI_LINTER_RULES" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" - TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" - TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path $PROTOBUF_LINTER_RULES" ".*\.\(proto\)\$" "protobuf" - TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES" ".*\.\(py\)\$" "python" + TestCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" ".*\.\(ymlopenapi\|jsonopenapi\)\$" "openapi" + TestCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "powershell" + TestCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "protobuf" + TestCodebase "PYTHON" "pylint" "pylint --rcfile ${PYTHON_LINTER_RULES}" ".*\.\(py\)\$" "python" TestCodebase "RAKU" "raku" "raku -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "raku" - TestCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES" ".*\.\(rb\)\$" "ruby" - TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" "terraform" - TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" "typescript" - TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" "typescript" + TestCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES}" ".*\.\(rb\)\$" "ruby" + TestCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "terraform" + TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" + TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "typescript" TestCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "xml" - TestCodebase "YML" "yamllint" "yamllint -c $YAML_LINTER_RULES" ".*\.\(yml\|yaml\)\$" "yml" + TestCodebase "YML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "yml" ################# # Footer prints # @@ -617,7 +617,7 @@ function LintAnsibleFiles() { ########################################### # Validate we have ansible-lint installed # ########################################### - VALIDATE_INSTALL_CMD=$(command -v "$LINTER_NAME" 2>&1) + VALIDATE_INSTALL_CMD=$(command -v "${LINTER_NAME}" 2>&1) ####################### # Load the error code # @@ -627,17 +627,17 @@ function LintAnsibleFiles() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then # Failed - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find $LINTER_NAME in system!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$VALIDATE_INSTALL_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Failed to find ${LINTER_NAME} in system!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${VALIDATE_INSTALL_CMD}]${NC}" exit 1 else # Success - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then # Success echo -e "${NC}${F[B]}Successfully found binary in system${NC}" - echo "Location:[$VALIDATE_INSTALL_CMD]" + echo "Location:[${VALIDATE_INSTALL_CMD}]" fi fi @@ -654,18 +654,18 @@ function LintAnsibleFiles() { ###################################################### # Only go into ansible linter if we have base folder # ###################################################### - if [ -d "$ANSIBLE_DIRECTORY" ]; then + if [ -d "${ANSIBLE_DIRECTORY}" ]; then ################################# # Get list of all files to lint # ################################# - mapfile -t LIST_FILES < <(ls "$ANSIBLE_DIRECTORY"/*.{yaml,yml} 2>&1) + mapfile -t LIST_FILES < <(ls "${ANSIBLE_DIRECTORY}"/*.{yaml,yml} 2>&1) ############################################################### # Set the list to empty if only MD and TXT files were changed # ############################################################### # No need to run the full ansible checks on read only file changes - if [ "$READ_ONLY_CHANGE_FLAG" -eq 0 ]; then + if [ "${READ_ONLY_CHANGE_FLAG}" -eq 0 ]; then ########################## # Set the array to empty # ########################## @@ -683,12 +683,12 @@ function LintAnsibleFiles() { #################################### # Check if we have data to look at # #################################### - if [ $SKIP_FLAG -eq 0 ]; then + if [ ${SKIP_FLAG} -eq 0 ]; then for LINE in "${PRINT_ARRAY[@]}"; do ######################### # Print the header line # ######################### - echo "$LINE" + echo "${LINE}" done fi @@ -710,7 +710,7 @@ function LintAnsibleFiles() { ######################################## # Make sure we dont lint certain files # ######################################## - if [[ $FILE == *"vault.yml"* ]] || [[ $FILE == *"galaxy.yml"* ]]; then + if [[ ${FILE} == *"vault.yml"* ]] || [[ ${FILE} == *"galaxy.yml"* ]]; then # This is a file we dont look at continue fi @@ -723,18 +723,18 @@ function LintAnsibleFiles() { #################### # Get the filename # #################### - FILE_NAME=$(basename "$ANSIBLE_DIRECTORY/$FILE" 2>&1) + FILE_NAME=$(basename "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) ############## # File print # ############## echo "---------------------------" - echo "File:[$FILE]" + echo "File:[${FILE}]" ################################ # Lint the file with the rules # ################################ - LINT_CMD=$("$LINTER_NAME" -v -c "$ANSIBLE_LINTER_RULES" "$ANSIBLE_DIRECTORY/$FILE" 2>&1) + LINT_CMD=$("${LINTER_NAME}" -v -c "${ANSIBLE_LINTER_RULES}" "${ANSIBLE_DIRECTORY}/${FILE}" 2>&1) ####################### # Load the error code # @@ -744,12 +744,12 @@ function LintAnsibleFiles() { ############################## # Check the shell for errors # ############################## - if [ $ERROR_CODE -ne 0 ]; then + if [ ${ERROR_CODE} -ne 0 ]; then ######### # Error # ######### - echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [$LINTER_NAME] linter!${NC}" - echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR!${NC} Found errors in [${LINTER_NAME}] linter!${NC}" + echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[${LINT_CMD}]${NC}" # Increment error count ((ERRORS_FOUND_ANSIBLE++)) @@ -765,7 +765,7 @@ function LintAnsibleFiles() { ########### # Success # ########### - echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}" + echo -e "${NC}${F[B]} - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully${NC}" ####################################################### # Store the linting as a temporary file in TAP format # @@ -787,11 +787,11 @@ function LintAnsibleFiles() { ############################### # Check to see if debug is on # ############################### - if [[ $ACTIONS_RUNNER_DEBUG == "true" ]]; then + if [[ ${ACTIONS_RUNNER_DEBUG} == "true" ]]; then ######################## # No Ansible dir found # ######################## - echo -e "${NC}${F[Y]}WARN!${NC} No Ansible base directory found at:[$ANSIBLE_DIRECTORY]${NC}" + echo -e "${NC}${F[Y]}WARN!${NC} No Ansible base directory found at:[${ANSIBLE_DIRECTORY}]${NC}" echo "skipping ansible lint" fi fi @@ -808,7 +808,7 @@ function IsTAP() { ################################################################################ #### Function TransformTAPDetails ############################################## function TransformTAPDetails() { - DATA=$1 + DATA=${1} if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ] ; then ######################################################### # Transform new lines to \\n, remove colours and colons # @@ -822,8 +822,8 @@ function HeaderTap() { ################ # Pull in Vars # ################ - INDEX="$1" # File being validated - OUTPUT_FILE="$2" # Output location + INDEX="${1}" # File being validated + OUTPUT_FILE="${2}" # Output location ################### # Print the goods # @@ -836,9 +836,9 @@ function OkTap() { ################ # Pull in Vars # ################ - INDEX="$1" # Location - FILE="$2" # File being validated - TEMP_FILE="$3" # Temp file location + INDEX="${1}" # Location + FILE="${2}" # File being validated + TEMP_FILE="${3}" # Temp file location ################### # Print the goods # @@ -851,9 +851,9 @@ function NotOkTap() { ################ # Pull in Vars # ################ - INDEX="$1" # Location - FILE="$2" # File being validated - TEMP_FILE="$3" # Temp file location + INDEX="${1}" # Location + FILE="${2}" # File being validated + TEMP_FILE="${3}" # Temp file location ################### # Print the goods # @@ -866,14 +866,14 @@ function AddDetailedMessageIfEnabled() { ################ # Pull in Vars # ################ - LINT_CMD="$1" # Linter command - TEMP_FILE="$2" # Temp file + LINT_CMD="${1}" # Linter command + TEMP_FILE="${2}" # Temp file #################### # Check the return # #################### DETAILED_MSG=$(TransformTAPDetails "${LINT_CMD}") if [ -n "${DETAILED_MSG}" ] ; then - printf " ---\n message: %s\n ...\n" "$DETAILED_MSG" >> "${TEMP_FILE}" + printf " ---\n message: %s\n ...\n" "${DETAILED_MSG}" >> "${TEMP_FILE}" fi }