mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 08:41:02 -05:00
adding some spaget
This commit is contained in:
parent
cfdcd9bd9c
commit
bce238d392
1 changed files with 115 additions and 53 deletions
|
@ -190,7 +190,13 @@ function BuildFileList() {
|
|||
######################
|
||||
# Get the BASH files #
|
||||
######################
|
||||
elif [ "${FILE_TYPE}" == "sh" ]; then
|
||||
elif [ "${FILE_TYPE}" == "sh" ] || [ "${FILE_TYPE}" == "bash" ] ||
|
||||
[ "${FILE_TYPE}" == "dash" ] || [ "${FILE_TYPE}" == "ksh" ]; then
|
||||
# Need to check if its a zsh file as we cannot parse it
|
||||
if CheckZsh "${FILE}"; then
|
||||
warn "Found [zsh] script"
|
||||
info "ShellCheck does NOT currently support zsh, skipping file"
|
||||
else
|
||||
################################
|
||||
# Append the file to the array #
|
||||
################################
|
||||
|
@ -199,6 +205,7 @@ function BuildFileList() {
|
|||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
fi
|
||||
######################
|
||||
# Get the PERL files #
|
||||
######################
|
||||
|
@ -506,6 +513,50 @@ function BuildFileList() {
|
|||
##############################################
|
||||
# Use file to see if we can parse what it is #
|
||||
##############################################
|
||||
CheckFileType "${FILE}"
|
||||
done
|
||||
|
||||
export READ_ONLY_CHANGE_FLAG # Workaround SC2034
|
||||
|
||||
#########################################
|
||||
# Need to switch back to branch of code #
|
||||
#########################################
|
||||
SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||
# Error
|
||||
error "Failed to switch back to branch!"
|
||||
fatal "[${SWITCH2_CMD}]"
|
||||
fi
|
||||
|
||||
################
|
||||
# Footer print #
|
||||
################
|
||||
info "----------------------------------------------"
|
||||
info "Successfully gathered list of files..."
|
||||
}
|
||||
################################################################################
|
||||
#### Function CheckFileType ####################################################
|
||||
function CheckFileType() {
|
||||
# Need to run the file through the 'file' exec to help determine
|
||||
# The type of file being parsed
|
||||
|
||||
################
|
||||
# Pull in Vars #
|
||||
################
|
||||
FILE="$1"
|
||||
|
||||
##################
|
||||
# Check the file #
|
||||
##################
|
||||
GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1)
|
||||
|
||||
#################
|
||||
|
@ -539,6 +590,12 @@ function BuildFileList() {
|
|||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
elif [[ ${GET_FILE_TYPE_CMD} == *"zsh script"* ]]; then
|
||||
######################
|
||||
# It is a ZSH script #
|
||||
######################
|
||||
warn "Found [zsh] script"
|
||||
info "ShellCheck does NOT currently support zsh, skipping file"
|
||||
else
|
||||
############################
|
||||
# Extension was not found! #
|
||||
|
@ -549,33 +606,38 @@ function BuildFileList() {
|
|||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
export READ_ONLY_CHANGE_FLAG # Workaround SC2034
|
||||
|
||||
#########################################
|
||||
# Need to switch back to branch of code #
|
||||
#########################################
|
||||
SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1)
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
#######################
|
||||
ERROR_CODE=$?
|
||||
|
||||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||
# Error
|
||||
error "Failed to switch back to branch!"
|
||||
fatal "[${SWITCH2_CMD}]"
|
||||
fi
|
||||
|
||||
################
|
||||
# Footer print #
|
||||
################
|
||||
info "----------------------------------------------"
|
||||
info "Successfully gathered list of files..."
|
||||
}
|
||||
################################################################################
|
||||
#### Function CheckZsh #########################################################
|
||||
function CheckZsh() {
|
||||
# Spagetti code to make sure were properly excluding zsh
|
||||
# until we get a proper linter
|
||||
|
||||
################
|
||||
# Pull in Vars #
|
||||
################
|
||||
FILE="$1"
|
||||
|
||||
##################
|
||||
# Check the file #
|
||||
##################
|
||||
GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1)
|
||||
|
||||
if [[ ${GET_FILE_TYPE_CMD} == *"zsh script"* ]]; then
|
||||
######################
|
||||
# It is a ZSH script #
|
||||
######################
|
||||
warn "Found [zsh] script"
|
||||
info "ShellCheck does NOT currently support zsh, skipping file"
|
||||
###################################################
|
||||
# We found zsh file and need to return with a hit #
|
||||
###################################################
|
||||
return 0
|
||||
else
|
||||
##################
|
||||
# Not a zsh file #
|
||||
##################
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue