mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-01 13:10:57 -05:00
commit
49b9b28c00
1 changed files with 45 additions and 7 deletions
|
@ -407,11 +407,16 @@ GetLinterRules() {
|
||||||
SECONDARY_FILE_NAME="$FILE_NAME.yml"
|
SECONDARY_FILE_NAME="$FILE_NAME.yml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# Set Flag for set Rules File #
|
||||||
|
###############################
|
||||||
|
SET_RULES=0
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Validate we have the linter rules #
|
# Validate we have the linter rules #
|
||||||
#####################################
|
#####################################
|
||||||
LANGUAGE_FILE_PATH="${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}"
|
LANGUAGE_FILE_PATH="${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${!LANGUAGE_FILE_NAME}"
|
||||||
debug "Checking if the user-provided ${!LANGUAGE_FILE_NAME} exists at ${LANGUAGE_FILE_PATH}"
|
debug "Checking if the user-provided:[${!LANGUAGE_FILE_NAME}] and exists at:[${LANGUAGE_FILE_PATH}]"
|
||||||
if [ -f "${LANGUAGE_FILE_PATH}" ]; then
|
if [ -f "${LANGUAGE_FILE_PATH}" ]; then
|
||||||
info "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
info "User provided file:[${LANGUAGE_FILE_PATH}] exists, setting rules file..."
|
info "User provided file:[${LANGUAGE_FILE_PATH}] exists, setting rules file..."
|
||||||
|
@ -420,12 +425,22 @@ GetLinterRules() {
|
||||||
# Update the path to the file location #
|
# Update the path to the file location #
|
||||||
########################################
|
########################################
|
||||||
eval "${LANGUAGE_LINTER_RULES}=${LANGUAGE_FILE_PATH}"
|
eval "${LANGUAGE_LINTER_RULES}=${LANGUAGE_FILE_PATH}"
|
||||||
|
######################
|
||||||
# Check if we have secondary file name to look for
|
# Set the rules flag #
|
||||||
elif [ -n "$SECONDARY_FILE_NAME" ]; then
|
######################
|
||||||
|
SET_RULES=1
|
||||||
|
else
|
||||||
|
# Failed to find the primary rules file
|
||||||
debug " -> Codebase does NOT have file:[${LANGUAGE_FILE_PATH}]."
|
debug " -> Codebase does NOT have file:[${LANGUAGE_FILE_PATH}]."
|
||||||
|
fi
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
# Check if we have secondary file name to look for #
|
||||||
|
####################################################
|
||||||
|
if [ -n "$SECONDARY_FILE_NAME" ] && [ "${SET_RULES}" -eq 0 ]; then
|
||||||
|
# Set the path
|
||||||
SECONDARY_LANGUAGE_FILE_PATH="${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}"
|
SECONDARY_LANGUAGE_FILE_PATH="${GITHUB_WORKSPACE}/${LINTER_RULES_PATH}/${SECONDARY_FILE_NAME}"
|
||||||
debug "${LANGUAGE_NAME} language rule file has a secondary rules file name to check (${SECONDARY_FILE_NAME}). Path: ${SECONDARY_LANGUAGE_FILE_PATH}"
|
debug "${LANGUAGE_NAME} language rule file has a secondary rules file name to check (${SECONDARY_FILE_NAME}). Path:[${SECONDARY_LANGUAGE_FILE_PATH}]"
|
||||||
|
|
||||||
if [ -f "${SECONDARY_LANGUAGE_FILE_PATH}" ]; then
|
if [ -f "${SECONDARY_LANGUAGE_FILE_PATH}" ]; then
|
||||||
info "----------------------------------------------"
|
info "----------------------------------------------"
|
||||||
|
@ -435,24 +450,47 @@ GetLinterRules() {
|
||||||
# Update the path to the file location #
|
# Update the path to the file location #
|
||||||
########################################
|
########################################
|
||||||
eval "${LANGUAGE_LINTER_RULES}=${SECONDARY_LANGUAGE_FILE_PATH}"
|
eval "${LANGUAGE_LINTER_RULES}=${SECONDARY_LANGUAGE_FILE_PATH}"
|
||||||
|
######################
|
||||||
|
# Set the rules flag #
|
||||||
|
######################
|
||||||
|
SET_RULES=1
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
# We didnt find rules from user, setting to default template #
|
||||||
|
##############################################################
|
||||||
|
if [ "${SET_RULES}" -eq 0 ]; then
|
||||||
########################################################
|
########################################################
|
||||||
# No user default provided, using the template default #
|
# No user default provided, using the template default #
|
||||||
########################################################
|
########################################################
|
||||||
eval "${LANGUAGE_LINTER_RULES}=${DEFAULT_RULES_LOCATION}/${!LANGUAGE_FILE_NAME}"
|
eval "${LANGUAGE_LINTER_RULES}=${DEFAULT_RULES_LOCATION}/${!LANGUAGE_FILE_NAME}"
|
||||||
debug " -> Codebase does NOT have file:[${LANGUAGE_FILE_PATH}], nor the file:[${SECONDARY_LANGUAGE_FILE_PATH}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]"
|
debug " -> Codebase does NOT have file:[${LANGUAGE_FILE_PATH}], nor the file:[${SECONDARY_LANGUAGE_FILE_PATH}], using Default rules at:[${!LANGUAGE_LINTER_RULES}]"
|
||||||
|
######################
|
||||||
|
# Set the rules flag #
|
||||||
|
######################
|
||||||
|
SET_RULES=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug " -> Language rules file variable (${LANGUAGE_LINTER_RULES}) value is: ${!LANGUAGE_LINTER_RULES}"
|
####################
|
||||||
|
# Debug Print info #
|
||||||
|
####################
|
||||||
|
debug " -> Language rules file variable (${LANGUAGE_LINTER_RULES}) value is:[${!LANGUAGE_LINTER_RULES}]"
|
||||||
|
|
||||||
|
############################
|
||||||
|
# Validate the file exists #
|
||||||
|
############################
|
||||||
if [ -e "${!LANGUAGE_LINTER_RULES}" ]; then
|
if [ -e "${!LANGUAGE_LINTER_RULES}" ]; then
|
||||||
|
# Found the rules file
|
||||||
debug " -> ${LANGUAGE_LINTER_RULES} rules file (${!LANGUAGE_LINTER_RULES}) exists."
|
debug " -> ${LANGUAGE_LINTER_RULES} rules file (${!LANGUAGE_LINTER_RULES}) exists."
|
||||||
else
|
else
|
||||||
# Here we expect a rules file, so fail if not available.
|
# Here we expect a rules file, so fail if not available.
|
||||||
fatal " -> ${LANGUAGE_LINTER_RULES} rules file (${!LANGUAGE_LINTER_RULES}) doesn't exist. Terminating..."
|
fatal " -> ${LANGUAGE_LINTER_RULES} rules file (${!LANGUAGE_LINTER_RULES}) doesn't exist. Terminating..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
######################
|
||||||
|
# Export the results #
|
||||||
|
######################
|
||||||
eval "export ${LANGUAGE_LINTER_RULES}"
|
eval "export ${LANGUAGE_LINTER_RULES}"
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in a new issue