mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-28 09:01:09 -05:00
Centralize file list building logic in buildFileList.sh
This commit is contained in:
parent
411ff990da
commit
68e15659b8
5 changed files with 152 additions and 394 deletions
|
@ -209,7 +209,6 @@ But if you wish to select or exclude specific linters, we give you full control
|
||||||
| **FILTER_REGEX_EXCLUDE** | `none` | Regular expression defining which files will be excluded from linting (ex: `.*src/test.*`) |
|
| **FILTER_REGEX_EXCLUDE** | `none` | Regular expression defining which files will be excluded from linting (ex: `.*src/test.*`) |
|
||||||
| **FILTER_REGEX_INCLUDE** | `all` | Regular expression defining which files will be processed by linters (ex: `.*src/.*`) |
|
| **FILTER_REGEX_INCLUDE** | `all` | Regular expression defining which files will be processed by linters (ex: `.*src/.*`) |
|
||||||
| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) |
|
| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) |
|
||||||
| **KUBERNETES_DIRECTORY** | `/kubernetes` | The path to the root directory for Kubernetes descriptors, relative to `DEFAULT_WORKSPACE`. |
|
|
||||||
| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. |
|
| **LINTER_RULES_PATH** | `.github/linters` | Directory for all linter configuration rules. |
|
||||||
| **LOG_FILE** | `super-linter.log` | The file name for outputting logs. All output is sent to the log file regardless of `LOG_LEVEL`. |
|
| **LOG_FILE** | `super-linter.log` | The file name for outputting logs. All output is sent to the log file regardless of `LOG_LEVEL`. |
|
||||||
| **LOG_LEVEL** | `VERBOSE` | How much output the script will generate to the console. One of `VERBOSE`, `DEBUG` or `TRACE`. |
|
| **LOG_LEVEL** | `VERBOSE` | How much output the script will generate to the console. One of `VERBOSE`, `DEBUG` or `TRACE`. |
|
||||||
|
|
|
@ -10,6 +10,15 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function BuildFileList ####################################################
|
#### Function BuildFileList ####################################################
|
||||||
function BuildFileList() {
|
function BuildFileList() {
|
||||||
|
debug "Building file list..."
|
||||||
|
|
||||||
|
################
|
||||||
|
# Pull in vars #
|
||||||
|
################
|
||||||
|
VALIDATE_ALL_CODEBASE="${1}"
|
||||||
|
debug "Validate all code base: ${VALIDATE_ALL_CODEBASE}..."
|
||||||
|
|
||||||
|
if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then
|
||||||
# Need to build a list of all files changed
|
# Need to build a list of all files changed
|
||||||
# This can be pulled from the GITHUB_EVENT_PATH payload
|
# This can be pulled from the GITHUB_EVENT_PATH payload
|
||||||
|
|
||||||
|
@ -51,6 +60,19 @@ function BuildFileList() {
|
||||||
# Get the Array of files changed in the commits #
|
# 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)
|
||||||
|
else
|
||||||
|
################
|
||||||
|
# print header #
|
||||||
|
################
|
||||||
|
debug "----------------------------------------------"
|
||||||
|
debug "Populating the file list with all the files in the ${GITHUB_WORKSPACE} workspace"
|
||||||
|
mapfile -t RAW_FILE_ARRAY < <(find "${GITHUB_WORKSPACE}" \
|
||||||
|
-path "*/node_modules" -prune -o \
|
||||||
|
-path "*/.git" -prune -o \
|
||||||
|
-path "*/.venv" -prune -o \
|
||||||
|
-path "*/.rbenv" -prune -o \
|
||||||
|
-type f 2>&1)
|
||||||
|
fi
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# Load the error code #
|
# Load the error code #
|
||||||
|
@ -69,24 +91,19 @@ function BuildFileList() {
|
||||||
################################################
|
################################################
|
||||||
# Iterate through the array of all files found #
|
# Iterate through the array of all files found #
|
||||||
################################################
|
################################################
|
||||||
info "----------------------------------------------"
|
info "---------------------------------"
|
||||||
info "------ Files modified in the commit(s): ------"
|
info "------ File list to check: ------"
|
||||||
info "----------------------------------------------"
|
info "---------------------------------"
|
||||||
for FILE in "${RAW_FILE_ARRAY[@]}"; do
|
for FILE in "${RAW_FILE_ARRAY[@]}"; do
|
||||||
# Extract just the file extension
|
# Extract just the file extension
|
||||||
FILE_TYPE="$(GetFileExtension "$FILE")"
|
FILE_TYPE="$(GetFileExtension "$FILE")"
|
||||||
# get the baseFile for additonal logic
|
# get the baseFile for additonal logic, lowercase
|
||||||
BASE_FILE=$(basename "${FILE,,}")
|
BASE_FILE=$(basename "${FILE,,}")
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# Print file #
|
# Print file #
|
||||||
##############
|
##############
|
||||||
info "File:[${FILE}], File_type:[${FILE_TYPE}], Base_file:[${BASE_FILE}]"
|
debug "File:[${FILE}], File_type:[${FILE_TYPE}], Base_file:[${BASE_FILE}]"
|
||||||
|
|
||||||
#########
|
|
||||||
# DEBUG #
|
|
||||||
#########
|
|
||||||
debug "FILE_TYPE:[${FILE_TYPE}]"
|
|
||||||
|
|
||||||
# Editorconfig-checker should check every file
|
# Editorconfig-checker should check every file
|
||||||
FILE_ARRAY_EDITORCONFIG+=("${FILE}")
|
FILE_ARRAY_EDITORCONFIG+=("${FILE}")
|
||||||
|
@ -152,11 +169,12 @@ function BuildFileList() {
|
||||||
########################
|
########################
|
||||||
# Get the DOCKER files #
|
# Get the DOCKER files #
|
||||||
########################
|
########################
|
||||||
elif [ "${FILE_TYPE}" == "dockerfile" ] || [[ "${BASE_FILE}" == *"dockerfile."* ]]; then
|
# Use BASE_FILE here because FILE_TYPE is not reliable when there is no file extension
|
||||||
|
elif [[ "${FILE_TYPE}" != "dockerfilelintrc" ]] && [[ "${BASE_FILE}" == *"dockerfile"* ]]; then
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
FILE_ARRAY_DOCKER+=("${FILE}")
|
FILE_ARRAY_DOCKERFILE+=("${FILE}")
|
||||||
FILE_ARRAY_DOCKERFILE_HADOLINT+=("${FILE}")
|
FILE_ARRAY_DOCKERFILE_HADOLINT+=("${FILE}")
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
@ -331,7 +349,13 @@ function BuildFileList() {
|
||||||
############################
|
############################
|
||||||
# Get the Powershell files #
|
# Get the Powershell files #
|
||||||
############################
|
############################
|
||||||
elif [ "${FILE_TYPE}" == "ps1" ]; then
|
elif [ "${FILE_TYPE}" == "ps1" ] ||
|
||||||
|
[ "${FILE_TYPE}" == "psm1" ] ||
|
||||||
|
[ "${FILE_TYPE}" == "psd1" ] ||
|
||||||
|
[ "${FILE_TYPE}" == "ps1xml" ] ||
|
||||||
|
[ "${FILE_TYPE}" == "pssc" ] ||
|
||||||
|
[ "${FILE_TYPE}" == "psrc" ] ||
|
||||||
|
[ "${FILE_TYPE}" == "cdxml" ]; then
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
@ -353,6 +377,7 @@ function BuildFileList() {
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
FILE_ARRAY_PYTHON_BLACK+=("${FILE}")
|
||||||
FILE_ARRAY_PYTHON_PYLINT+=("${FILE}")
|
FILE_ARRAY_PYTHON_PYLINT+=("${FILE}")
|
||||||
FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}")
|
FILE_ARRAY_PYTHON_FLAKE8+=("${FILE}")
|
||||||
|
|
||||||
|
@ -388,7 +413,7 @@ function BuildFileList() {
|
||||||
###########################
|
###########################
|
||||||
# Get the SNAKEMAKE files #
|
# Get the SNAKEMAKE files #
|
||||||
###########################
|
###########################
|
||||||
elif [ "${FILE_TYPE}" == "smk" ] || [ "${BASE_FILE}" == "Snakefile" ]; then
|
elif [ "${FILE_TYPE}" == "smk" ] || [ "${BASE_FILE}" == "snakefile" ]; then
|
||||||
################################
|
################################
|
||||||
# Append the file to the array #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
@ -470,7 +495,6 @@ function BuildFileList() {
|
||||||
################################
|
################################
|
||||||
FILE_ARRAY_KUBERNETES_KUBEVAL+=("${FILE}")
|
FILE_ARRAY_KUBERNETES_KUBEVAL+=("${FILE}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# We have something that we need to try to check file type another way #
|
# We have something that we need to try to check file type another way #
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -482,6 +506,7 @@ function BuildFileList() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then
|
||||||
#########################################
|
#########################################
|
||||||
# Need to switch back to branch of code #
|
# Need to switch back to branch of code #
|
||||||
#########################################
|
#########################################
|
||||||
|
@ -500,6 +525,7 @@ function BuildFileList() {
|
||||||
error "Failed to switch back to branch!"
|
error "Failed to switch back to branch!"
|
||||||
fatal "[${SWITCH2_CMD}]"
|
fatal "[${SWITCH2_CMD}]"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
# Footer print #
|
# Footer print #
|
||||||
|
@ -541,17 +567,7 @@ function CheckFileType() {
|
||||||
#################
|
#################
|
||||||
GET_FILE_TYPE_CMD="$(GetFileType "$FILE")"
|
GET_FILE_TYPE_CMD="$(GetFileType "$FILE")"
|
||||||
|
|
||||||
#################
|
if [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then
|
||||||
# Check if bash #
|
|
||||||
#################
|
|
||||||
if IsValidShellScript "$FILE"; then
|
|
||||||
################################
|
|
||||||
# Append the file to the array #
|
|
||||||
################################
|
|
||||||
FILE_ARRAY_BASH+=("${FILE}")
|
|
||||||
FILE_ARRAY_BASH_EXEC+=("${FILE}")
|
|
||||||
FILE_ARRAY_SHELL_SHFMT+=("${FILE}")
|
|
||||||
elif [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then
|
|
||||||
#######################
|
#######################
|
||||||
# It is a Ruby script #
|
# It is a Ruby script #
|
||||||
#######################
|
#######################
|
||||||
|
@ -628,33 +644,3 @@ function IsValidShellScript() {
|
||||||
trace "$FILE is NOT a supported shell script. Skipping"
|
trace "$FILE is NOT a supported shell script. Skipping"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
################################################################################
|
|
||||||
#### Function IsValidShellScript ###############################################
|
|
||||||
function PopulateShellScriptsList() {
|
|
||||||
debug "Populating shell script file list. Source: ${GITHUB_WORKSPACE}"
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
||||||
###############################################################################
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" \
|
|
||||||
-path "*/node_modules" -prune -o \
|
|
||||||
-path "*/.git" -prune -o \
|
|
||||||
-path "*/.venv" -prune -o \
|
|
||||||
-path "*/.rbenv" -prune -o \
|
|
||||||
-type f 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if IsValidShellScript "${FILE}"; then
|
|
||||||
debug "Adding ${FILE} to shell script files list"
|
|
||||||
FILE_ARRAY_BASH+=("${FILE}")
|
|
||||||
FILE_ARRAY_BASH_EXEC+=("${FILE}")
|
|
||||||
FILE_ARRAY_SHELL_SHFMT+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
}
|
|
||||||
|
|
282
lib/linter.sh
282
lib/linter.sh
|
@ -191,7 +191,6 @@ GITHUB_RUN_ID="${GITHUB_RUN_ID}" # GitHub RU
|
||||||
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
GITHUB_SHA="${GITHUB_SHA}" # GitHub sha from the commit
|
||||||
GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment
|
GITHUB_TOKEN="${GITHUB_TOKEN}" # GitHub Token passed from environment
|
||||||
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}" # Github Workspace
|
||||||
KUBERNETES_DIRECTORY="${KUBERNETES_DIRECTORY}" # Kubernetes directory
|
|
||||||
MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran
|
MULTI_STATUS="${MULTI_STATUS:-true}" # Multiple status are created for each check ran
|
||||||
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
||||||
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files
|
VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean to validate all files
|
||||||
|
@ -203,7 +202,6 @@ DEFAULT_VALIDATE_ALL_CODEBASE='true' # Default value for validate
|
||||||
DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally
|
DEFAULT_WORKSPACE="${DEFAULT_WORKSPACE:-/tmp/lint}" # Default workspace if running locally
|
||||||
DEFAULT_RUN_LOCAL='false' # Default value for debugging 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_TEST_CASE_RUN='false' # Flag to tell code to run only test cases
|
||||||
DEFAULT_IFS="${IFS}" # Get the Default IFS for updating
|
|
||||||
|
|
||||||
###############################################################
|
###############################################################
|
||||||
# Default Vars that are called in Subs and need to be ignored #
|
# Default Vars that are called in Subs and need to be ignored #
|
||||||
|
@ -574,7 +572,7 @@ DetectAWSStatesFIle() {
|
||||||
###############################
|
###############################
|
||||||
# check if file has resources #
|
# check if file has resources #
|
||||||
###############################
|
###############################
|
||||||
if grep '"Resource": *"arn"*' "${FILE}"; then
|
if grep -q '"Resource": *"arn"*' "${FILE}"; then
|
||||||
# Found it
|
# Found it
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -1050,8 +1048,6 @@ GetGitHubVars
|
||||||
########################################################
|
########################################################
|
||||||
DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory
|
DEFAULT_ANSIBLE_DIRECTORY="${GITHUB_WORKSPACE}/ansible" # Default Ansible Directory
|
||||||
export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034
|
export DEFAULT_ANSIBLE_DIRECTORY # Workaround SC2034
|
||||||
DEFAULT_KUBERNETES_DIRECTORY="${GITHUB_WORKSPACE}/kubernetes" # Default Kubernetes Directory
|
|
||||||
export DEFAULT_KUBERNETES_DIRECTORY # Workaround SC2034
|
|
||||||
REPORT_OUTPUT_FOLDER="${GITHUB_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the report folder
|
REPORT_OUTPUT_FOLDER="${GITHUB_WORKSPACE}/${OUTPUT_FOLDER}" # Location for the report folder
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
|
@ -1149,15 +1145,10 @@ if [[ ${TEST_CASE_RUN} != "false" ]]; then
|
||||||
RunTestCases
|
RunTestCases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#############################################
|
###########################################
|
||||||
# check flag for validation of all codebase #
|
# Build the list of files for each linter #
|
||||||
#############################################
|
###########################################
|
||||||
if [ "${VALIDATE_ALL_CODEBASE}" == "false" ]; then
|
BuildFileList "${VALIDATE_ALL_CODEBASE}"
|
||||||
########################################
|
|
||||||
# Get list of files changed if env set #
|
|
||||||
########################################
|
|
||||||
BuildFileList
|
|
||||||
fi
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# ANSIBLE LINTING #
|
# ANSIBLE LINTING #
|
||||||
|
@ -1176,31 +1167,10 @@ fi
|
||||||
# ARM Template LINTING #
|
# ARM Template LINTING #
|
||||||
########################
|
########################
|
||||||
if [ "${VALIDATE_ARM}" == "true" ]; then
|
if [ "${VALIDATE_ARM}" == "true" ]; then
|
||||||
# If we are validating all codebase we need to build file list because not every json file is an ARM file
|
|
||||||
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}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectARMFile "${FILE}"; then
|
|
||||||
FILE_ARRAY_ARM+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Lint the ARM Template files #
|
# Lint the ARM Template files #
|
||||||
###############################
|
###############################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ARM[@]}"
|
||||||
LintCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ARM[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1210,8 +1180,7 @@ if [ "${VALIDATE_BASH}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the bash files #
|
# Lint the bash files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH[@]}"
|
||||||
LintCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
@ -1221,39 +1190,17 @@ if [ "${VALIDATE_BASH_EXEC}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the bash files #
|
# Lint the bash files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "BASH_EXEC" "bash-exec" "bash-exec" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH[@]}"
|
||||||
LintCodebase "BASH_EXEC" "bash-exec" "bash-exec" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_BASH_EXEC[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# CLOUDFORMATION LINTING #
|
# CLOUDFORMATION LINTING #
|
||||||
##########################
|
##########################
|
||||||
if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then
|
if [ "${VALIDATE_CLOUDFORMATION}" == "true" ]; then
|
||||||
# If we are validating all codebase we need to build file list because not every yml/json file is an CLOUDFORMATION file
|
|
||||||
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}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectCloudFormationFile "${FILE}"; then
|
|
||||||
FILE_ARRAY_CLOUDFORMATION+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
# Lint the CloudFormation files #
|
# Lint the CloudFormation files #
|
||||||
#################################
|
#################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOUDFORMATION[@]}"
|
||||||
LintCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOUDFORMATION[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###################
|
###################
|
||||||
|
@ -1267,7 +1214,7 @@ if [ "${VALIDATE_CLOJURE}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the Clojure files #
|
# Lint the Clojure files #
|
||||||
#########################
|
#########################
|
||||||
LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOJURE[@]}"
|
LintCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CLOJURE[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
@ -1277,8 +1224,7 @@ if [ "${VALIDATE_COFFEE}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the coffee files #
|
# Lint the coffee files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_COFFEESCRIPT[@]}"
|
||||||
LintCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_COFFEESCRIPT[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
@ -1288,8 +1234,7 @@ if [ "${VALIDATE_CSHARP}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the C# files #
|
# Lint the C# files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "CSHARP" "dotnet-format" "dotnet-format --folder --check --exclude / --include" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSHARP[@]}"
|
||||||
LintCodebase "CSHARP" "dotnet-format" "dotnet-format --folder --check --exclude / --include" ".*\.\(cs\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSHARP[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -1303,7 +1248,7 @@ if [ "${VALIDATE_CSS}" == "true" ]; then
|
||||||
#############################
|
#############################
|
||||||
# Lint the CSS files #
|
# Lint the CSS files #
|
||||||
#############################
|
#############################
|
||||||
LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" ".*\.\(css\|scss\|sass\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSS[@]}"
|
LintCodebase "CSS" "stylelint" "stylelint --config ${CSS_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_CSS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1313,9 +1258,7 @@ if [ "${VALIDATE_DART}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the Dart files #
|
# Lint the Dart files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DART[@]}"
|
||||||
# shellcheck disable=SC2153
|
|
||||||
LintCodebase "DART" "dart" "dartanalyzer --fatal-infos --fatal-warnings --options ${DART_LINTER_RULES}" ".*\.\(dart\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DART[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
@ -1325,9 +1268,8 @@ if [ "${VALIDATE_DOCKERFILE}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the docker files #
|
# Lint the docker files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
|
||||||
# NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file
|
# NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file
|
||||||
LintCodebase "DOCKERFILE" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKERFILE_LINTER_RULES})" ".*\(Dockerfile\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE[@]}"
|
LintCodebase "DOCKERFILE" "dockerfilelint" "dockerfilelint -c $(dirname ${DOCKERFILE_LINTER_RULES})" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
|
@ -1337,8 +1279,7 @@ if [ "${VALIDATE_DOCKERFILE_HADOLINT}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the docker files #
|
# Lint the docker files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "DOCKERFILE_HADOLINT" "hadolint" "hadolint -c ${DOCKERFILE_HADOLINT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE_HADOLINT[@]}"
|
||||||
LintCodebase "DOCKERFILE_HADOLINT" "hadolint" "hadolint -c ${DOCKERFILE_HADOLINT_LINTER_RULES}" ".*\(Dockerfile\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_DOCKERFILE_HADOLINT[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
@ -1348,8 +1289,7 @@ if [ "${VALIDATE_EDITORCONFIG}" == "true" ]; then
|
||||||
####################################
|
####################################
|
||||||
# Lint the files with editorconfig #
|
# Lint the files with editorconfig #
|
||||||
####################################
|
####################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_EDITORCONFIG[@]}"
|
||||||
LintCodebase "EDITORCONFIG" "editorconfig-checker" "editorconfig-checker" "^.*$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_EDITORCONFIG[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -1359,8 +1299,7 @@ if [ "${VALIDATE_ENV}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the env files #
|
# Lint the env files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "ENV" "dotenv-linter" "dotenv-linter" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ENV[@]}"
|
||||||
LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_ENV[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
@ -1370,8 +1309,7 @@ if [ "${VALIDATE_GO}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the golang files #
|
# Lint the golang files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GO[@]}"
|
||||||
LintCodebase "GO" "golangci-lint" "golangci-lint run -c ${GO_LINTER_RULES}" ".*\.\(go\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GO[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
@ -1381,8 +1319,7 @@ if [ "$VALIDATE_GROOVY" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the groovy files #
|
# Lint the groovy files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon warning" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GROOVY[@]}"
|
||||||
LintCodebase "GROOVY" "npm-groovy-lint" "npm-groovy-lint -c $GROOVY_LINTER_RULES --failon warning" ".*\.\(groovy\|jenkinsfile\|gradle\|nf\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_GROOVY[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1396,7 +1333,7 @@ if [ "${VALIDATE_HTML}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the HTML files #
|
# Lint the HTML files #
|
||||||
#######################
|
#######################
|
||||||
LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" ".*\.\(html\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_HTML[@]}"
|
LintCodebase "HTML" "htmlhint" "htmlhint --config ${HTML_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_HTML[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1406,8 +1343,7 @@ if [ "$VALIDATE_JAVA" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the JAVA files #
|
# Lint the JAVA files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVA[@]}"
|
||||||
LintCodebase "JAVA" "checkstyle" "java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}" ".*\.\(java\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVA[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -1417,8 +1353,7 @@ if [ "${VALIDATE_JAVASCRIPT_ES}" == "true" ]; then
|
||||||
#############################
|
#############################
|
||||||
# Lint the Javascript files #
|
# Lint the Javascript files #
|
||||||
#############################
|
#############################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_ES[@]}"
|
||||||
LintCodebase "JAVASCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(js\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_ES[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -1432,8 +1367,7 @@ if [ "${VALIDATE_JAVASCRIPT_STANDARD}" == "true" ]; then
|
||||||
#############################
|
#############################
|
||||||
# Lint the Javascript files #
|
# Lint the Javascript files #
|
||||||
#############################
|
#############################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}"
|
||||||
LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard ${JAVASCRIPT_STANDARD_LINTER_RULES}" ".*\.\(js\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1443,8 +1377,7 @@ if [ "${VALIDATE_JSON}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the json files #
|
# Lint the json files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "JSON" "jsonlint" "jsonlint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JSON[@]}"
|
||||||
LintCodebase "JSON" "jsonlint" "jsonlint" ".*\.\(json\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JSON[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -1454,50 +1387,24 @@ if [ "${VALIDATE_JSX}" == "true" ]; then
|
||||||
######################
|
######################
|
||||||
# Lint the JSX files #
|
# Lint the JSX files #
|
||||||
######################
|
######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JSX[@]}"
|
||||||
LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c ${JAVASCRIPT_LINTER_RULES}" ".*\.\(jsx\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_JSX[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# KOTLIN LINTING #
|
# KOTLIN LINTING #
|
||||||
##################
|
##################
|
||||||
if [ "${VALIDATE_KOTLIN}" == "true" ]; then
|
if [ "${VALIDATE_KOTLIN}" == "true" ]; then
|
||||||
#######################
|
#########################
|
||||||
# Lint the Kotlin files #
|
# Lint the Kotlin files #
|
||||||
#######################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "KOTLIN" "ktlint" "ktlint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KOTLIN[@]}"
|
||||||
LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KOTLIN[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
# KUBERNETES Kubeval LINTING #
|
# KUBERNETES Kubeval LINTING #
|
||||||
##############################
|
##############################
|
||||||
if [ "${VALIDATE_KUBERNETES_KUBEVAL}" == "true" ]; then
|
if [ "${VALIDATE_KUBERNETES_KUBEVAL}" == "true" ]; then
|
||||||
if [ -d "${KUBERNETES_DIRECTORY}" ]; then
|
LintCodebase "KUBERNETES_KUBEVAL" "kubeval" "kubeval --strict" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KUBERNETES_KUBEVAL[@]}"
|
||||||
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 "${KUBERNETES_DIRECTORY}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectKubernetesFile "${FILE}"; then
|
|
||||||
FILE_ARRAY_KUBERNETES_KUBEVAL+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
LintCodebase "KUBERNETES_KUBEVAL" "kubeval" "kubeval --strict" ".*\.\(yml\|yaml\|json\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_KUBERNETES_KUBEVAL[@]}"
|
|
||||||
else
|
|
||||||
warn "No Kubernetes directory found at:[${KUBERNETES_DIRECTORY}]"
|
|
||||||
debug "skipping Kubeval lint"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
@ -1507,8 +1414,7 @@ if [ "${VALIDATE_LATEX}" == "true" ]; then
|
||||||
########################
|
########################
|
||||||
# Lint the LATEX files #
|
# Lint the LATEX files #
|
||||||
########################
|
########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "LATEX" "chktex" "chktex -q -l ${LATEX_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LATEX[@]}"
|
||||||
LintCodebase "LATEX" "chktex" "chktex -q -l ${LATEX_LINTER_RULES}" ".*\.\(tex\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LATEX[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -1518,8 +1424,7 @@ if [ "${VALIDATE_LUA}" == "true" ]; then
|
||||||
######################
|
######################
|
||||||
# Lint the Lua files #
|
# Lint the Lua files #
|
||||||
######################
|
######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LUA[@]}"
|
||||||
LintCodebase "LUA" "lua" "luacheck --config ${LUA_LINTER_RULES}" ".*\.\(lua\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_LUA[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
####################
|
####################
|
||||||
|
@ -1529,39 +1434,17 @@ if [ "${VALIDATE_MARKDOWN}" == "true" ]; then
|
||||||
###########################
|
###########################
|
||||||
# Lint the Markdown Files #
|
# Lint the Markdown Files #
|
||||||
###########################
|
###########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_MARKDOWN[@]}"
|
||||||
LintCodebase "MARKDOWN" "markdownlint" "markdownlint -c ${MARKDOWN_LINTER_RULES}" ".*\.\(md\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_MARKDOWN[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# OPENAPI LINTING #
|
# 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
|
|
||||||
###############################################################################
|
|
||||||
# Set the file seperator to newline to allow for grabbing objects with spaces #
|
|
||||||
###############################################################################
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(yml\|yaml\|json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectOpenAPIFile "${FILE}"; then
|
|
||||||
FILE_ARRAY_OPENAPI+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# Lint the OpenAPI files #
|
# Lint the OpenAPI files #
|
||||||
##########################
|
##########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_OPENAPI[@]}"
|
||||||
LintCodebase "OPENAPI" "spectral" "spectral lint -r ${OPENAPI_LINTER_RULES}" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_OPENAPI[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1571,8 +1454,7 @@ if [ "${VALIDATE_PERL}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the perl files #
|
# Lint the perl files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PERL" "perl" "perlcritic" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PERL[@]}"
|
||||||
LintCodebase "PERL" "perl" "perlcritic" ".*\.\(pl\|pm\|t\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PERL[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1582,32 +1464,28 @@ if [ "${VALIDATE_PHP_BUILTIN}" == "true" ]; then
|
||||||
################################################
|
################################################
|
||||||
# Lint the PHP files using built-in PHP linter #
|
# Lint the PHP files using built-in PHP linter #
|
||||||
################################################
|
################################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PHP_BUILTIN" "php" "php -l" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_BUILTIN[@]}"
|
||||||
LintCodebase "PHP_BUILTIN" "php" "php -l" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_BUILTIN[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${VALIDATE_PHP_PHPCS}" == "true" ]; then
|
if [ "${VALIDATE_PHP_PHPCS}" == "true" ]; then
|
||||||
############################################
|
############################################
|
||||||
# Lint the PHP files using PHP CodeSniffer #
|
# Lint the PHP files using PHP CodeSniffer #
|
||||||
############################################
|
############################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPCS[@]}"
|
||||||
LintCodebase "PHP_PHPCS" "phpcs" "phpcs --standard=${PHP_PHPCS_LINTER_RULES}" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPCS[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then
|
if [ "${VALIDATE_PHP_PHPSTAN}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the PHP files using PHPStan #
|
# Lint the PHP files using PHPStan #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPSTAN[@]}"
|
||||||
LintCodebase "PHP_PHPSTAN" "phpstan" "phpstan analyse --no-progress --no-ansi -c ${PHP_PHPSTAN_LINTER_RULES}" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PHPSTAN[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then
|
if [ "${VALIDATE_PHP_PSALM}" == "true" ]; then
|
||||||
##################################
|
##################################
|
||||||
# Lint the PHP files using Psalm #
|
# Lint the PHP files using Psalm #
|
||||||
##################################
|
##################################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PSALM[@]}"
|
||||||
LintCodebase "PHP_PSALM" "psalm" "psalm --config=${PHP_PSALM_LINTER_RULES}" ".*\.\(php\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PHP_PSALM[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -1622,8 +1500,7 @@ if [ "${VALIDATE_POWERSHELL}" == "true" ]; then
|
||||||
#############################
|
#############################
|
||||||
# Lint the powershell files #
|
# Lint the powershell files #
|
||||||
#############################
|
#############################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_POWERSHELL[@]}"
|
||||||
LintCodebase "POWERSHELL" "pwsh" "Invoke-ScriptAnalyzer -EnableExit -Settings ${POWERSHELL_LINTER_RULES} -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_POWERSHELL[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
####################
|
####################
|
||||||
|
@ -1633,8 +1510,7 @@ if [ "${VALIDATE_PROTOBUF}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the Protocol Buffers files #
|
# Lint the Protocol Buffers files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PROTOBUF[@]}"
|
||||||
LintCodebase "PROTOBUF" "protolint" "protolint lint --config_path ${PROTOBUF_LINTER_RULES}" ".*\.\(proto\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PROTOBUF[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
@ -1644,8 +1520,7 @@ if [ "${VALIDATE_PYTHON_BLACK}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the python files #
|
# Lint the python files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PYTHON_BLACK" "black" "black --config ${PYTHON_BLACK_LINTER_RULES} --diff --check" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_BLACK[@]}"
|
||||||
LintCodebase "PYTHON_BLACK" "black" "black --config ${PYTHON_BLACK_LINTER_RULES} --diff --check" ".*\.\(py\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_BLACK[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
@ -1655,8 +1530,7 @@ if [ "${VALIDATE_PYTHON_PYLINT}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the python files #
|
# Lint the python files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_PYLINT[@]}"
|
||||||
LintCodebase "PYTHON_PYLINT" "pylint" "pylint --rcfile ${PYTHON_PYLINT_LINTER_RULES}" ".*\.\(py\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_PYLINT[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
@ -1666,8 +1540,7 @@ if [ "${VALIDATE_PYTHON_FLAKE8}" == "true" ]; then
|
||||||
#########################
|
#########################
|
||||||
# Lint the python files #
|
# Lint the python files #
|
||||||
#########################
|
#########################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_FLAKE8[@]}"
|
||||||
LintCodebase "PYTHON_FLAKE8" "flake8" "flake8 --config=${PYTHON_FLAKE8_LINTER_RULES}" ".*\.\(py\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_PYTHON_FLAKE8[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#############
|
#############
|
||||||
|
@ -1686,7 +1559,7 @@ if [ "${VALIDATE_R}" == "true" ]; then
|
||||||
######################
|
######################
|
||||||
# Lint the R files #
|
# Lint the R files #
|
||||||
######################
|
######################
|
||||||
LintCodebase "R" "lintr" "lintr::lint(File)" ".*\.\(r\|R\|Rmd\|rmd\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_R[@]}"
|
LintCodebase "R" "lintr" "lintr::lint(File)" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_R[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1699,8 +1572,7 @@ if [ "${VALIDATE_RAKU}" == "true" ]; then
|
||||||
if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then
|
if [ -e "${GITHUB_WORKSPACE}/META6.json" ]; then
|
||||||
cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test .
|
cd "${GITHUB_WORKSPACE}" && zef install --deps-only --/test .
|
||||||
fi
|
fi
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RAKU[@]}"
|
||||||
LintCodebase "RAKU" "raku" "raku -I ${GITHUB_WORKSPACE}/lib -c" ".*\.\(raku\|rakumod\|rakutest\|pm6\|pl6\|p6\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RAKU[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1710,8 +1582,7 @@ if [ "${VALIDATE_RUBY}" == "true" ]; then
|
||||||
#######################
|
#######################
|
||||||
# Lint the ruby files #
|
# Lint the ruby files #
|
||||||
#######################
|
#######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RUBY[@]}"
|
||||||
LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" ".*\.\(rb\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_RUBY[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
@ -1723,8 +1594,7 @@ if [ "${VALIDATE_SHELL_SHFMT}" == "true" ]; then
|
||||||
####################################
|
####################################
|
||||||
EDITORCONFIG_FILE_PATH="${GITHUB_WORKSPACE}"/.editorconfig
|
EDITORCONFIG_FILE_PATH="${GITHUB_WORKSPACE}"/.editorconfig
|
||||||
if [ -e "$EDITORCONFIG_FILE_PATH" ]; then
|
if [ -e "$EDITORCONFIG_FILE_PATH" ]; then
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "SHELL_SHFMT" "shfmt" "shfmt -d" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SHELL_SHFMT[@]}"
|
||||||
LintCodebase "SHELL_SHFMT" "shfmt" "shfmt -d" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SHELL_SHFMT[@]}"
|
|
||||||
else
|
else
|
||||||
###############################
|
###############################
|
||||||
# No .editorconfig file found #
|
# No .editorconfig file found #
|
||||||
|
@ -1738,53 +1608,24 @@ fi
|
||||||
# SNAKEMAKE LINT #
|
# SNAKEMAKE LINT #
|
||||||
##################
|
##################
|
||||||
if [ "${VALIDATE_SNAKEMAKE_LINT}" == "true" ]; then
|
if [ "${VALIDATE_SNAKEMAKE_LINT}" == "true" ]; then
|
||||||
################################
|
LintCodebase "SNAKEMAKE_LINT" "snakemake" "snakemake --lint -s" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE_LINT[@]}"
|
||||||
# Lint the files with snakefmt #
|
|
||||||
################################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
|
||||||
LintCodebase "SNAKEMAKE_LINT" "snakemake" "snakemake --lint -s" ".*\(Snakefile\|\.smk\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE_LINT[@]}"
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# SNAKEMAKE SNAKEFMT #
|
# SNAKEMAKE SNAKEFMT #
|
||||||
######################
|
######################
|
||||||
if [ "${VALIDATE_SNAKEMAKE_SNAKEFMT}" == "true" ]; then
|
if [ "${VALIDATE_SNAKEMAKE_SNAKEFMT}" == "true" ]; then
|
||||||
################################
|
LintCodebase "SNAKEMAKE_SNAKEFMT" "snakefmt" "snakefmt --config ${SNAKEMAKE_SNAKEFMT_LINTER_RULES} --check --compact-diff" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE_SNAKEFMT[@]}"
|
||||||
# Lint the files with snakefmt #
|
|
||||||
################################
|
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
|
||||||
LintCodebase "SNAKEMAKE_SNAKEFMT" "snakefmt" "snakefmt --config ${SNAKEMAKE_SNAKEFMT_LINTER_RULES} --check --compact-diff" ".*\(Snakefile\|\.smk\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SNAKEMAKE_SNAKEFMT[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
# AWS STATES LINTING #
|
# AWS STATES LINTING #
|
||||||
######################
|
######################
|
||||||
if [ "${VALIDATE_STATES}" == "true" ]; then
|
if [ "${VALIDATE_STATES}" == "true" ]; then
|
||||||
# If we are validating all codebase we need to build file list because not every json file is an aws states file
|
|
||||||
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}" -path "*/node_modules" -prune -o -type f -regex ".*\.\(json\)\$" 2>&1)
|
|
||||||
for FILE in "${LIST_FILES[@]}"; do
|
|
||||||
if DetectAWSStatesFIle "${FILE}"; then
|
|
||||||
FILE_ARRAY_STATES+=("${FILE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# Lint the STATES files #
|
# Lint the STATES files #
|
||||||
#########################
|
#########################
|
||||||
LintCodebase "STATES" "asl-validator" "asl-validator --json-path" "disabledfileext" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_STATES[@]}"
|
LintCodebase "STATES" "asl-validator" "asl-validator --json-path" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_STATES[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -1794,8 +1635,7 @@ if [ "${VALIDATE_SQL}" == "true" ]; then
|
||||||
######################
|
######################
|
||||||
# Lint the SQL files #
|
# Lint the SQL files #
|
||||||
######################
|
######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "SQL" "sql-lint" "sql-lint --config ${SQL_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SQL[@]}"
|
||||||
LintCodebase "SQL" "sql-lint" "sql-lint --config ${SQL_LINTER_RULES}" ".*\.\(sql\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_SQL[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
@ -1805,8 +1645,7 @@ if [ "${VALIDATE_TERRAFORM}" == "true" ]; then
|
||||||
############################
|
############################
|
||||||
# Lint the Terraform files #
|
# Lint the Terraform files #
|
||||||
############################
|
############################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM[@]}"
|
||||||
LintCodebase "TERRAFORM" "tflint" "tflint -c ${TERRAFORM_LINTER_RULES}" ".*\.\(tf\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
|
@ -1816,8 +1655,7 @@ if [ "${VALIDATE_TERRAFORM_TERRASCAN}" == "true" ]; then
|
||||||
############################
|
############################
|
||||||
# Lint the Terraform files #
|
# Lint the Terraform files #
|
||||||
############################
|
############################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan scan -p /root/.terrascan/pkg/policies/opa/rego/ -t aws -f " "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}"
|
||||||
LintCodebase "TERRAFORM_TERRASCAN" "terrascan" "terrascan scan -p /root/.terrascan/pkg/policies/opa/rego/ -t aws -f " ".*\.\(tf\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TERRAFORM_TERRASCAN[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -1827,7 +1665,7 @@ if [ "${VALIDATE_TSX}" == "true" ]; then
|
||||||
######################
|
######################
|
||||||
# Lint the TSX files #
|
# Lint the TSX files #
|
||||||
######################
|
######################
|
||||||
LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(tsx\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TSX[@]}"
|
LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TSX[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -1837,7 +1675,7 @@ if [ "${VALIDATE_TYPESCRIPT_ES}" == "true" ]; then
|
||||||
#############################
|
#############################
|
||||||
# Lint the Typescript files #
|
# Lint the Typescript files #
|
||||||
#############################
|
#############################
|
||||||
LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" ".*\.\(ts\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_ES[@]}"
|
LintCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c ${TYPESCRIPT_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_ES[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -1851,7 +1689,7 @@ if [ "${VALIDATE_TYPESCRIPT_STANDARD}" == "true" ]; then
|
||||||
#############################
|
#############################
|
||||||
# Lint the Typescript files #
|
# Lint the Typescript files #
|
||||||
#############################
|
#############################
|
||||||
LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" ".*\.\(ts\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}"
|
LintCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin ${TYPESCRIPT_STANDARD_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_TYPESCRIPT_STANDARD[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -1861,8 +1699,7 @@ if [ "${VALIDATE_XML}" == "true" ]; then
|
||||||
######################
|
######################
|
||||||
# Lint the XML Files #
|
# Lint the XML Files #
|
||||||
######################
|
######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "XML" "xmllint" "xmllint" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_XML[@]}"
|
||||||
LintCodebase "XML" "xmllint" "xmllint" ".*\.\(xml\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_XML[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################
|
################
|
||||||
|
@ -1872,8 +1709,7 @@ if [ "${VALIDATE_YAML}" == "true" ]; then
|
||||||
######################
|
######################
|
||||||
# Lint the Yml Files #
|
# Lint the Yml Files #
|
||||||
######################
|
######################
|
||||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILTER_REGEX_INCLUDE" "FILTER_REGEX_EXCLUDE" "FILE_ARRAY"
|
LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_YAML[@]}"
|
||||||
LintCodebase "YAML" "yamllint" "yamllint -c ${YAML_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "${FILTER_REGEX_INCLUDE}" "${FILTER_REGEX_EXCLUDE}" "${FILE_ARRAY_YAML[@]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###########
|
###########
|
||||||
|
|
|
@ -146,26 +146,6 @@ function GetValidationInfo() {
|
||||||
debug "Setting Ansible directory to: ${ANSIBLE_DIRECTORY}"
|
debug "Setting Ansible directory to: ${ANSIBLE_DIRECTORY}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#################################
|
|
||||||
# Validate Kubernetes Directory #
|
|
||||||
#################################
|
|
||||||
if [ -z "${KUBERNETES_DIRECTORY}" ]; then
|
|
||||||
# No Value, need to default
|
|
||||||
KUBERNETES_DIRECTORY="${DEFAULT_KUBERNETES_DIRECTORY}"
|
|
||||||
debug "Setting Kubernetes directory to the default: ${DEFAULT_KUBERNETES_DIRECTORY}"
|
|
||||||
else
|
|
||||||
# Check if first char is '/'
|
|
||||||
if [[ ${KUBERNETES_DIRECTORY:0:1} == "/" ]]; then
|
|
||||||
# Remove first char
|
|
||||||
KUBERNETES_DIRECTORY="${KUBERNETES_DIRECTORY:1}"
|
|
||||||
fi
|
|
||||||
# Need to give it full path
|
|
||||||
TEMP_KUBERNETES_DIRECTORY="${GITHUB_WORKSPACE}/${KUBERNETES_DIRECTORY}"
|
|
||||||
# Set the value
|
|
||||||
KUBERNETES_DIRECTORY="${TEMP_KUBERNETES_DIRECTORY}"
|
|
||||||
debug "Setting Kubernetes directory to: ${KUBERNETES_DIRECTORY}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Get the disable errors flag #
|
# Get the disable errors flag #
|
||||||
###############################
|
###############################
|
||||||
|
|
|
@ -16,7 +16,6 @@ function LintCodebase() {
|
||||||
FILE_TYPE="${1}" && shift # Pull the variable and remove from array path (Example: 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_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)
|
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)
|
|
||||||
FILTER_REGEX_INCLUDE="${1}" && shift # Pull the variable and remove from array path (Example: */src/*,*/test/*)
|
FILTER_REGEX_INCLUDE="${1}" && shift # Pull the variable and remove from array path (Example: */src/*,*/test/*)
|
||||||
FILTER_REGEX_EXCLUDE="${1}" && shift # Pull the variable and remove from array path (Example: */examples/*,*/test/*.test)
|
FILTER_REGEX_EXCLUDE="${1}" && shift # Pull the variable and remove from array path (Example: */examples/*,*/test/*.test)
|
||||||
FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON})
|
FILE_ARRAY=("$@") # Array of files to validate (Example: ${FILE_ARRAY_JSON})
|
||||||
|
@ -75,54 +74,12 @@ function LintCodebase() {
|
||||||
############################################################
|
############################################################
|
||||||
# Check to see if we need to go through array or all files #
|
# 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 ]; then
|
||||||
# No files found in commit and user has asked to not validate code base
|
|
||||||
SKIP_FLAG=1
|
SKIP_FLAG=1
|
||||||
debug " - No files found in changeset to lint for language:[${FILE_TYPE}]"
|
debug " - No files found in changeset to lint for language:[${FILE_TYPE}]"
|
||||||
elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then
|
else
|
||||||
# We have files added to array of files to check
|
# We have files added to array of files to check
|
||||||
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
|
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
|
||||||
else
|
|
||||||
if [[ ${FILE_TYPE} == "BASH" ]] ||
|
|
||||||
[[ ${FILE_TYPE} == "BASH_EXEC" ]] ||
|
|
||||||
[[ ${FILE_TYPE} == "SHELL_SHFMT" ]]; then
|
|
||||||
# Populate a list of valid shell scripts.
|
|
||||||
PopulateShellScriptsList
|
|
||||||
else
|
|
||||||
###############################################################################
|
|
||||||
# Set the file separator to newline to allow for grabbing objects with spaces #
|
|
||||||
###############################################################################
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Get list of all files to lint #
|
|
||||||
#################################
|
|
||||||
mapfile -t LIST_FILES < <(find "${GITHUB_WORKSPACE}" \
|
|
||||||
-path "*/node_modules" -prune -o \
|
|
||||||
-path "*/.git" -prune -o \
|
|
||||||
-path "*/.venv" -prune -o \
|
|
||||||
-path "*/.rbenv" -prune -o \
|
|
||||||
-type f -regex "${FILE_EXTENSIONS}" 2>&1)
|
|
||||||
|
|
||||||
###########################
|
|
||||||
# Set IFS back to default #
|
|
||||||
###########################
|
|
||||||
IFS="${DEFAULT_IFS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
############################################################
|
|
||||||
# Set it back to empty if loaded with blanks from scanning #
|
|
||||||
############################################################
|
|
||||||
if [ ${#LIST_FILES[@]} -lt 1 ]; then
|
|
||||||
######################
|
|
||||||
# Set to empty array #
|
|
||||||
######################
|
|
||||||
LIST_FILES=()
|
|
||||||
#############################
|
|
||||||
# Skip as we found no files #
|
|
||||||
#############################
|
|
||||||
SKIP_FLAG=1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
|
|
Loading…
Reference in a new issue