mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 22:20:57 -05:00
commit
dbf6b0387e
1 changed files with 114 additions and 52 deletions
|
@ -190,7 +190,13 @@ function BuildFileList() {
|
||||||
######################
|
######################
|
||||||
# Get the BASH files #
|
# 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 #
|
# Append the file to the array #
|
||||||
################################
|
################################
|
||||||
|
@ -199,6 +205,7 @@ function BuildFileList() {
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
READ_ONLY_CHANGE_FLAG=1
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
|
fi
|
||||||
######################
|
######################
|
||||||
# Get the PERL files #
|
# Get the PERL files #
|
||||||
######################
|
######################
|
||||||
|
@ -506,6 +513,51 @@ function BuildFileList() {
|
||||||
##############################################
|
##############################################
|
||||||
# Use file to see if we can parse what it is #
|
# Use file to see if we can parse what it is #
|
||||||
##############################################
|
##############################################
|
||||||
|
CheckFileType "${FILE}"
|
||||||
|
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 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)
|
GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1)
|
||||||
|
|
||||||
#################
|
#################
|
||||||
|
@ -539,6 +591,12 @@ function BuildFileList() {
|
||||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||||
##########################################################
|
##########################################################
|
||||||
READ_ONLY_CHANGE_FLAG=1
|
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
|
else
|
||||||
############################
|
############################
|
||||||
# Extension was not found! #
|
# Extension was not found! #
|
||||||
|
@ -549,33 +607,37 @@ function BuildFileList() {
|
||||||
##########################################################
|
##########################################################
|
||||||
READ_ONLY_CHANGE_FLAG=1
|
READ_ONLY_CHANGE_FLAG=1
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
done
|
################################################################################
|
||||||
|
#### Function CheckZsh #########################################################
|
||||||
export READ_ONLY_CHANGE_FLAG # Workaround SC2034
|
function CheckZsh() {
|
||||||
|
# Spagetti code to make sure were properly excluding zsh
|
||||||
#########################################
|
# until we get a proper linter
|
||||||
# Need to switch back to branch of code #
|
|
||||||
#########################################
|
################
|
||||||
SWITCH2_CMD=$(git -C "${GITHUB_WORKSPACE}" checkout --progress --force "${GITHUB_SHA}" 2>&1)
|
# Pull in Vars #
|
||||||
|
################
|
||||||
#######################
|
FILE="$1"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
##################
|
||||||
ERROR_CODE=$?
|
# Check the file #
|
||||||
|
##################
|
||||||
##############################
|
GET_FILE_TYPE_CMD=$(file "${FILE}" 2>&1)
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
if [[ ${GET_FILE_TYPE_CMD} == *"zsh script"* ]]; then
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
######################
|
||||||
# Error
|
# It is a ZSH script #
|
||||||
error "Failed to switch back to branch!"
|
######################
|
||||||
fatal "[${SWITCH2_CMD}]"
|
warn "Found [zsh] script"
|
||||||
fi
|
info "ShellCheck does NOT currently support zsh, skipping file"
|
||||||
|
###################################################
|
||||||
################
|
# We found zsh file and need to return with a hit #
|
||||||
# Footer print #
|
###################################################
|
||||||
################
|
return 0
|
||||||
info "----------------------------------------------"
|
else
|
||||||
info "Successfully gathered list of files..."
|
##################
|
||||||
|
# Not a zsh file #
|
||||||
|
##################
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue