mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-09 02:23:39 -05:00
fix: handle log messages in CheckFileType (#5117)
- Honor SUPPRESS_FILE_TYPE_WARN when printing messages in the CheckFileType function. - Reduce duplication when handling log messages in the CheckFileType function. - Don't add files to the array of files to lint with JSCPD because we lint the whole codebase with JSCPD anyway.
This commit is contained in:
parent
fa2d870b80
commit
5a2056d77a
1 changed files with 12 additions and 28 deletions
|
@ -172,41 +172,25 @@ function CheckFileType() {
|
||||||
|
|
||||||
GET_FILE_TYPE_CMD="$(GetFileType "$FILE")"
|
GET_FILE_TYPE_CMD="$(GetFileType "$FILE")"
|
||||||
|
|
||||||
|
local FILE_TYPE_MESSAGE
|
||||||
|
|
||||||
if [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then
|
if [[ ${GET_FILE_TYPE_CMD} == *"Ruby script"* ]]; then
|
||||||
if [ "${SUPPRESS_FILE_TYPE_WARN}" == "false" ]; then
|
FILE_TYPE_MESSAGE="Found Ruby script without extension (${FILE}). Rename the file with proper extension for Ruby files."
|
||||||
warn "Found ruby script without extension:[.rb]"
|
|
||||||
info "Please update file with proper extensions."
|
|
||||||
fi
|
|
||||||
################################
|
|
||||||
# Append the file to the array #
|
|
||||||
################################
|
|
||||||
FILE_ARRAY_JSCPD+=("${FILE}")
|
|
||||||
FILE_ARRAY_RUBY+=("${FILE}")
|
FILE_ARRAY_RUBY+=("${FILE}")
|
||||||
elif [[ ${GET_FILE_TYPE_CMD} == *"Python script"* ]]; then
|
elif [[ ${GET_FILE_TYPE_CMD} == *"Python script"* ]]; then
|
||||||
if [ "${SUPPRESS_FILE_TYPE_WARN}" == "false" ]; then
|
FILE_TYPE_MESSAGE="Found Python script without extension (${FILE}). Rename the file with proper extension for Python files."
|
||||||
warn "Found Python script without extension:[.py]"
|
|
||||||
info "Please update file with proper extensions."
|
|
||||||
fi
|
|
||||||
################################
|
|
||||||
# Append the file to the array #
|
|
||||||
################################
|
|
||||||
FILE_ARRAY_JSCPD+=("${FILE}")
|
|
||||||
FILE_ARRAY_PYTHON+=("${FILE}")
|
FILE_ARRAY_PYTHON+=("${FILE}")
|
||||||
elif [[ ${GET_FILE_TYPE_CMD} == *"Perl script"* ]]; then
|
elif [[ ${GET_FILE_TYPE_CMD} == *"Perl script"* ]]; then
|
||||||
if [ "${SUPPRESS_FILE_TYPE_WARN}" == "false" ]; then
|
FILE_TYPE_MESSAGE="Found Perl script without extension (${FILE}). Rename the file with proper extension for Perl files."
|
||||||
warn "Found Perl script without extension:[.pl]"
|
|
||||||
info "Please update file with proper extensions."
|
|
||||||
fi
|
|
||||||
################################
|
|
||||||
# Append the file to the array #
|
|
||||||
################################
|
|
||||||
FILE_ARRAY_JSCPD+=("${FILE}")
|
|
||||||
FILE_ARRAY_PERL+=("${FILE}")
|
FILE_ARRAY_PERL+=("${FILE}")
|
||||||
else
|
else
|
||||||
############################
|
FILE_TYPE_MESSAGE="Failed to get file type for: ${FILE}"
|
||||||
# Extension was not found! #
|
fi
|
||||||
############################
|
|
||||||
debug "Failed to get filetype for:[${FILE}]!"
|
if [ "${SUPPRESS_FILE_TYPE_WARN}" == "false" ]; then
|
||||||
|
warn "${FILE_TYPE_MESSAGE}"
|
||||||
|
else
|
||||||
|
debug "${FILE_TYPE_MESSAGE}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue