mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-29 12:10:56 -05:00
commit
10f44786ce
5 changed files with 42 additions and 11 deletions
0
.automation/test/shell/shell_good_1.sh
Normal file → Executable file
0
.automation/test/shell/shell_good_1.sh
Normal file → Executable file
|
@ -216,6 +216,12 @@ RUN wget --tries=5 https://storage.googleapis.com/dart-archive/channels/stable/r
|
||||||
&& mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ \
|
&& mv dart-sdk/bin/* /usr/bin/ && mv dart-sdk/lib/* /usr/lib/ && mv dart-sdk/include/* /usr/include/ \
|
||||||
&& rm -r dart-sdk/
|
&& rm -r dart-sdk/
|
||||||
|
|
||||||
|
################################
|
||||||
|
# Create and install Bash-Exec #
|
||||||
|
################################
|
||||||
|
RUN printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: File:[$1] is not executable"; exit 1; fi' > /usr/bin/bash-exec \
|
||||||
|
&& chmod +x /usr/bin/bash-exec
|
||||||
|
|
||||||
################
|
################
|
||||||
# Install Raku #
|
# Install Raku #
|
||||||
################
|
################
|
||||||
|
@ -291,6 +297,7 @@ ENV ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \
|
||||||
VALIDATE_ANSIBLE=${VALIDATE_ANSIBLE} \
|
VALIDATE_ANSIBLE=${VALIDATE_ANSIBLE} \
|
||||||
VALIDATE_ARM=${VALIDATE_ARM} \
|
VALIDATE_ARM=${VALIDATE_ARM} \
|
||||||
VALIDATE_BASH=${VALIDATE_BASH} \
|
VALIDATE_BASH=${VALIDATE_BASH} \
|
||||||
|
VALIDATE_BASH_EXEC=${VALIDATE_BASH_EXEC} \
|
||||||
VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \
|
VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \
|
||||||
VALIDATE_CLOUDFORMATION=${VALIDATE_CLOUDFORMATION} \
|
VALIDATE_CLOUDFORMATION=${VALIDATE_CLOUDFORMATION} \
|
||||||
VALIDATE_COFFEE=${VALIDATE_COFFEE} \
|
VALIDATE_COFFEE=${VALIDATE_COFFEE} \
|
||||||
|
|
|
@ -72,7 +72,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
||||||
| **R** | [lintr](https://github.com/jimhester/lintr) |
|
| **R** | [lintr](https://github.com/jimhester/lintr) |
|
||||||
| **Raku** | [Raku](https://raku.org) |
|
| **Raku** | [Raku](https://raku.org) |
|
||||||
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
||||||
| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) |
|
| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) / [Bash-exec] |
|
||||||
| **SQL** | [sql-lint](https://github.com/joereynolds/sql-lint) |
|
| **SQL** | [sql-lint](https://github.com/joereynolds/sql-lint) |
|
||||||
| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) / [terrascan](https://github.com/accurics/terrascan) |
|
| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) / [terrascan](https://github.com/accurics/terrascan) |
|
||||||
| **TypeScript** | [eslint](https://eslint.org/) / [standard js](https://standardjs.com/) |
|
| **TypeScript** | [eslint](https://eslint.org/) / [standard js](https://standardjs.com/) |
|
||||||
|
@ -196,6 +196,7 @@ But if you wish to select or exclude specific linters, we give you full control
|
||||||
| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. |
|
| **VALIDATE_ANSIBLE** | `true` | Flag to enable or disable the linting process of the Ansible language. |
|
||||||
| **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. |
|
| **VALIDATE_ARM** | `true` | Flag to enable or disable the linting process of the ARM language. |
|
||||||
| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. |
|
| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the Bash language. |
|
||||||
|
| **VALIDATE_BASH_EXEC** | `true` | Flag to enable or disable the linting process of the Bash language to validate if file is stored as executable. |
|
||||||
| **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the Clojure language. |
|
| **VALIDATE_CLOJURE** | `true` | Flag to enable or disable the linting process of the Clojure language. |
|
||||||
| **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the AWS Cloud Formation language. |
|
| **VALIDATE_CLOUDFORMATION** | `true` | Flag to enable or disable the linting process of the AWS Cloud Formation language. |
|
||||||
| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the Coffeescript language . |
|
| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the Coffeescript language . |
|
||||||
|
|
|
@ -133,7 +133,7 @@ YAML_LINTER_RULES="${DEFAULT_RULES_LOCATION}/${YAML_FILE_NAME}" # Path to the ya
|
||||||
#######################################
|
#######################################
|
||||||
# Linter array for information prints #
|
# Linter array for information prints #
|
||||||
#######################################
|
#######################################
|
||||||
LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'black' 'cfn-lint' 'checkstyle' 'chktex' 'clj-kondo' 'coffeelint'
|
LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'black' 'bash-exec' 'cfn-lint' 'checkstyle' 'chktex' 'clj-kondo' 'coffeelint'
|
||||||
'dart' 'dockerfilelint' 'dotenv-linter' 'editorconfig-checker' 'eslint' 'flake8' 'golangci-lint'
|
'dart' 'dockerfilelint' 'dotenv-linter' 'editorconfig-checker' 'eslint' 'flake8' 'golangci-lint'
|
||||||
'hadolint' 'htmlhint' 'jsonlint' 'ktlint' 'lintr' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint'
|
'hadolint' 'htmlhint' 'jsonlint' 'ktlint' 'lintr' 'lua' 'markdownlint' 'npm-groovy-lint' 'perl' 'protolint'
|
||||||
'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint'
|
'pwsh' 'pylint' 'raku' 'rubocop' 'shellcheck' 'spectral' 'standard' 'stylelint' 'sql-lint'
|
||||||
|
@ -142,7 +142,7 @@ LINTER_ARRAY=('ansible-lint' 'arm-ttk' 'asl-validator' 'black' 'cfn-lint' 'check
|
||||||
#############################
|
#############################
|
||||||
# Language array for prints #
|
# Language array for prints #
|
||||||
#############################
|
#############################
|
||||||
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS'
|
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CSS'
|
||||||
'DART' 'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GO' 'GROOVY' 'HTML'
|
'DART' 'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GO' 'GROOVY' 'HTML'
|
||||||
'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
'JAVA' 'JAVASCRIPT_ES' 'JAVASCRIPT_STANDARD' 'JSON' 'JSX' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
||||||
'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL'
|
'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL'
|
||||||
|
@ -174,6 +174,7 @@ VALIDATE_ALL_CODEBASE="${VALIDATE_ALL_CODEBASE}" # Boolean t
|
||||||
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
|
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
|
||||||
VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language
|
VALIDATE_ARM="${VALIDATE_ARM}" # Boolean to validate language
|
||||||
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
||||||
|
VALIDATE_BASH_EXEC="${VALIDATE_BASH_EXEC}" # Boolean to validate language
|
||||||
VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language
|
VALIDATE_CLOUDFORMATION="${VALIDATE_CLOUDFORMATION}" # Boolean to validate language
|
||||||
VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language
|
VALIDATE_CLOJURE="${VALIDATE_CLOJURE}" # Boolean to validate language
|
||||||
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
||||||
|
@ -327,6 +328,8 @@ ERRORS_FOUND_ARM=0 # Count of errors found
|
||||||
export ERRORS_FOUND_ARM # Workaround SC2034
|
export ERRORS_FOUND_ARM # Workaround SC2034
|
||||||
ERRORS_FOUND_BASH=0 # Count of errors found
|
ERRORS_FOUND_BASH=0 # Count of errors found
|
||||||
export ERRORS_FOUND_BASH # Workaround SC2034
|
export ERRORS_FOUND_BASH # Workaround SC2034
|
||||||
|
ERRORS_FOUND_BASH_EXEC=0 # Count of errors found
|
||||||
|
export ERRORS_FOUND_BASH_EXEC # Workaround SC2034
|
||||||
ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found
|
ERRORS_FOUND_CLOUDFORMATION=0 # Count of errors found
|
||||||
export ERRORS_FOUND_CLOUDFORMATION # Workaround SC2034
|
export ERRORS_FOUND_CLOUDFORMATION # Workaround SC2034
|
||||||
ERRORS_FOUND_CLOJURE=0 # Count of errors found
|
ERRORS_FOUND_CLOJURE=0 # Count of errors found
|
||||||
|
@ -1362,6 +1365,17 @@ if [ "${VALIDATE_BASH}" == "true" ]; then
|
||||||
LintCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}"
|
LintCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# BASH_EXEC LINTING #
|
||||||
|
#####################
|
||||||
|
if [ "${VALIDATE_BASH_EXEC}" == "true" ]; then
|
||||||
|
#######################
|
||||||
|
# Lint the bash files #
|
||||||
|
#######################
|
||||||
|
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||||
|
LintCodebase "BASH_EXEC" "bash-exec" "bash-exec" ".*\.\(sh\|bash\|dash\|ksh\)\$" "${FILE_ARRAY_BASH[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# CLOUDFORMATION LINTING #
|
# CLOUDFORMATION LINTING #
|
||||||
##########################
|
##########################
|
||||||
|
|
|
@ -247,14 +247,22 @@ function LintCodebase() {
|
||||||
# Check the shell for errors #
|
# Check the shell for errors #
|
||||||
##############################
|
##############################
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||||
#########
|
if [[ ${FILE_TYPE} == "BASH_EXEC" ]]; then
|
||||||
# Error #
|
########
|
||||||
#########
|
# WARN #
|
||||||
error "Found errors in [${LINTER_NAME}] linter!"
|
########
|
||||||
error "[${LINT_CMD}]"
|
warn "Warnings found in [${LINTER_NAME}] linter!"
|
||||||
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]"
|
warn "${LINT_CMD}"
|
||||||
# Increment the error count
|
else
|
||||||
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
#########
|
||||||
|
# Error #
|
||||||
|
#########
|
||||||
|
error "Found errors in [${LINTER_NAME}] linter!"
|
||||||
|
error "[${LINT_CMD}]"
|
||||||
|
error "Linter CMD:[${LINTER_COMMAND} ${FILE}]"
|
||||||
|
# Increment the error count
|
||||||
|
(("ERRORS_FOUND_${FILE_TYPE}++"))
|
||||||
|
fi
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
# Store the linting as a temporary file in TAP format #
|
# Store the linting as a temporary file in TAP format #
|
||||||
|
@ -614,6 +622,7 @@ function RunTestCases() {
|
||||||
TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible"
|
TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c ${ANSIBLE_LINTER_RULES}" ".*\.\(yml\|yaml\)\$" "ansible"
|
||||||
TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm"
|
TestCodebase "ARM" "arm-ttk" "Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" ".*\.\(json\)\$" "arm"
|
||||||
TestCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell"
|
TestCodebase "BASH" "shellcheck" "shellcheck --color --external-sources" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell"
|
||||||
|
TestCodebase "BASH_EXEC" "bash-exec" "bash-exec" ".*\.\(sh\|bash\|dash\|ksh\)\$" "shell"
|
||||||
TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation"
|
TestCodebase "CLOUDFORMATION" "cfn-lint" "cfn-lint --config-file ${CLOUDFORMATION_LINTER_RULES}" ".*\.\(json\|yml\|yaml\)\$" "cloudformation"
|
||||||
TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure"
|
TestCodebase "CLOJURE" "clj-kondo" "clj-kondo --config ${CLOJURE_LINTER_RULES} --lint" ".*\.\(clj\|cljs\|cljc\|edn\)\$" "clojure"
|
||||||
TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript"
|
TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f ${COFFEESCRIPT_LINTER_RULES}" ".*\.\(coffee\)\$" "coffeescript"
|
||||||
|
|
Loading…
Reference in a new issue