diff --git a/lib/linter.sh b/lib/linter.sh index 93bcc695..c2e54bd7 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -70,8 +70,8 @@ JAVASCRIPT_STANDARD_LINTER_RULES='' # EN # Default linter path LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory # LaTeX Vars -LATEX_FILE_NAME='.chktexrc' # Name of the file -LATEX_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LATEX_FILE_NAME}" # Path to the Latex lint rules # env var to supress warning from chktex +LATEX_FILE_NAME='.chktexrc' # Name of the file +LATEX_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LATEX_FILE_NAME}" # Path to the Latex lint rules # Lua Vars LUA_FILE_NAME='.luacheckrc' # Name of the file LUA_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${LUA_FILE_NAME}" # Path to the Lua lint rules @@ -136,7 +136,7 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the ya LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'bash-exec' 'black' 'cfn-lint' 'checkstyle' 'chktex' 'clj-kondo' 'coffeelint' 'dotnet-format' 'dart' 'dockerfilelint' 'dotenv-linter' 'editorconfig-checker' 'eslint' 'flake8' 'golangci-lint' 'hadolint' 'htmlhint' 'jsonlint' 'ktlint' 'lintr' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint' - 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'shfmt' 'spectral' 'standard' 'stylelint' 'sql-lint' + 'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint' 'terrascan' 'tflint' 'xmllint' 'yamllint') ############################# @@ -146,7 +146,7 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CLOUDFORMATION' 'CLOJURE' 'C 'DART' 'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GO' 'GROOVY' 'HTML' 'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL' - 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'R' 'RAKU' 'RUBY' 'SHELL_SHFMT' 'STATES' 'SQL' 'TERRAFORM' + 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'R' 'RAKU' 'RUBY' 'STATES' 'SQL' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML') ############################################ @@ -211,7 +211,6 @@ VALIDATE_R="${VALIDATE_R}" # Boolean t VALIDATE_RAKU="${VALIDATE_RAKU}" # Boolean to validate language VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language VALIDATE_STATES="${VALIDATE_STATES}" # Boolean to validate language -VALIDATE_SHELL_SHFMT="${VALIDATE_SHELL_SHFMT}" # Boolean to check Shell files against editorconfig VALIDATE_SQL="${VALIDATE_SQL}" # Boolean to validate language VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language VALIDATE_TERRAFORM_TERRASCAN="${VALIDATE_TERRAFORM_TERRASCAN}" # Boolean to validate language @@ -405,8 +404,6 @@ ERRORS_FOUND_RAKU=0 # Count of errors found export ERRORS_FOUND_RAKU # Workaround SC2034 ERRORS_FOUND_RUBY=0 # Count of errors found export ERRORS_FOUND_RUBY # Workaround SC2034 -ERRORS_FOUND_SHELL_SHFMT=0 # Count of errors found -export ERRORS_FOUND_SHELL_SHFMT ERRORS_FOUND_STATES=0 # Count of errors found export ERRORS_FOUND_STATES # Workaround SC2034 ERRORS_FOUND_SQL=0 # Count of errors found @@ -467,7 +464,7 @@ GetLinterVersions() { if [[ ${LINTER} == "arm-ttk" ]]; then # Need specific command for ARM mapfile -t GET_VERSION_CMD < <(grep -iE 'version' "${ARM_TTK_PSD1}" | xargs 2>&1) - elif [[ ${LINTER} == "protolint" ]] || [[ ${LINTER} == "editorconfig-checker" ]] || [[ ${LINTER} == "bash-exec" ]]; then + elif [[ ${LINTER} == "protolint" ]] || [[ ${LINTER} == "editorconfig-checker" ]]; then # Need specific command for Protolint and editorconfig-checker mapfile -t GET_VERSION_CMD < <(echo "--version not supported") elif [[ ${LINTER} == "lintr" ]]; then @@ -478,8 +475,6 @@ GetLinterVersions() { elif [[ ${LINTER} == "lua" ]]; then # Semi standardversion command mapfile -t GET_VERSION_CMD < <("${LINTER}" -v 2>&1) - elif [[ ${LINTER} == "terrascan" ]]; then - mapfile -t GET_VERSION_CMD < <("${LINTER}" version 2>&1) else # Standard version command mapfile -t GET_VERSION_CMD < <("${LINTER}" --version 2>&1) @@ -1070,13 +1065,9 @@ Reports() { ############################################# # Print info on reports that were generated # ############################################# - if [ -d "${REPORT_OUTPUT_FOLDER}" ]; then - info "Contents of report folder:" - OUTPUT_CONTENTS_CMD=$(ls "${REPORT_OUTPUT_FOLDER}") - info "$OUTPUT_CONTENTS_CMD" - else - warn "Report output folder (${REPORT_OUTPUT_FOLDER}) does NOT exist." - fi + info "Contents of report folder:" + OUTPUT_CONTENTS_CMD=$(ls "${REPORT_OUTPUT_FOLDER}") + info "$OUTPUT_CONTENTS_CMD" fi ################################ @@ -1845,26 +1836,6 @@ if [ "${VALIDATE_RUBY}" == "true" ]; then LintCodebase "RUBY" "rubocop" "rubocop -c ${RUBY_LINTER_RULES} --force-exclusion" ".*\.\(rb\)\$" "${FILE_ARRAY_RUBY[@]}" fi -################# -# SHFMT LINTING # -################# -if [ "${VALIDATE_SHELL_SHFMT}" == "true" ]; then - #################################### - # Lint the files with shfmt # - #################################### - EDITORCONFIG_FILE_PATH="${GITHUB_WORKSPACE}"/.editorconfig - if [ -e "$EDITORCONFIG_FILE_PATH" ]; then - # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "SHELL_SHFMT" "shfmt" "shfmt -d" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}" - else - ############################### - # No .editorconfig file found # - ############################### - warn "No .editorconfig found at:[$EDITORCONFIG_FILE_PATH]" - debug "skipping shfmt" - fi -fi - ###################### # AWS STATES LINTING # ###################### diff --git a/lib/worker.sh b/lib/worker.sh index 25614675..8cfed3ca 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -163,14 +163,11 @@ function LintCodebase() { elif [[ ${FILE} == *".rbenv"* ]]; then # This is likely the ruby environment folder and shouldn't be parsed continue - elif [[ ${FILE_TYPE} == "BASH" ]] && CheckZsh "${FILE}"; then - # ZSH file and we need to skip - warn "$LINTER_NAME does NOT currently support zsh, skipping file" - continue - elif [[ ${FILE_TYPE} == "SHELL_SHFMT" ]] && CheckZsh "${FILE}"; then - # ZSH file and we need to skip - warn "$LINTER_NAME does NOT currently support zsh, skipping file" - continue + elif [[ ${FILE_TYPE} == "BASH" ]] || [[ ${FILE_TYPE} == "SHELL_SHFMT" ]]; then + if CheckZsh "${FILE}"; then + # ZSH file and we need to skip + warn "$LINTER_NAME does NOT currently support zsh, skipping file" + continue fi ##################################