mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-25 07:31:05 -05:00
chore: extract language array definition (#5945)
Move LANGUAGE_ARRAY definition and initialization to a dedicated file (globals/languages.sh) so we can source it in different places without having to source the whole linter.sh
This commit is contained in:
parent
c5ba6872c6
commit
d9592327c6
12 changed files with 61 additions and 31 deletions
10
Makefile
10
Makefile
|
@ -281,7 +281,15 @@ lint-subset-files-enable-expensive-io-checks: ## Lint a small subset of files in
|
||||||
$(SUPER_LINTER_TEST_CONTAINER_URL)
|
$(SUPER_LINTER_TEST_CONTAINER_URL)
|
||||||
|
|
||||||
.PHONY: test-lib
|
.PHONY: test-lib
|
||||||
test-lib: test-build-file-list test-detect-files test-github-event test-setup-ssh test-validation test-output ## Test super-linter
|
test-lib: test-globals-languages test-build-file-list test-detect-files test-github-event test-setup-ssh test-validation test-output ## Test super-linter libs and globals
|
||||||
|
|
||||||
|
.PHONY: test-globals-languages
|
||||||
|
test-globals-languages: ## Test globals/languages.sh
|
||||||
|
docker run \
|
||||||
|
-v "$(CURDIR):/tmp/lint" \
|
||||||
|
-w /tmp/lint \
|
||||||
|
--entrypoint /tmp/lint/test/lib/globalsLanguagesTest.sh \
|
||||||
|
$(SUPER_LINTER_TEST_CONTAINER_URL)
|
||||||
|
|
||||||
.PHONY: test-build-file-list
|
.PHONY: test-build-file-list
|
||||||
test-build-file-list: ## Test buildFileList
|
test-build-file-list: ## Test buildFileList
|
||||||
|
|
|
@ -90,6 +90,7 @@ new tool, it should include:
|
||||||
- Update the orchestration scripts to run the new tool:
|
- Update the orchestration scripts to run the new tool:
|
||||||
|
|
||||||
- `lib/linter.sh`
|
- `lib/linter.sh`
|
||||||
|
- `globals/languages.sh`
|
||||||
- `lib/functions/linterCommands.sh`
|
- `lib/functions/linterCommands.sh`
|
||||||
- Provide the logic to populate the list of files or directories to examine: `lib/buildFileList.sh`
|
- Provide the logic to populate the list of files or directories to examine: `lib/buildFileList.sh`
|
||||||
- If necessary, provide elaborate logic to detect if the tool should examine a file or a directory: `lib/detectFiles.sh`
|
- If necessary, provide elaborate logic to detect if the tool should examine a file or a directory: `lib/detectFiles.sh`
|
||||||
|
|
17
lib/globals/languages.sh
Executable file
17
lib/globals/languages.sh
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
|
||||||
|
'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CPP' 'CSHARP' 'CSS' 'DART'
|
||||||
|
'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GITHUB_ACTIONS'
|
||||||
|
'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GO_RELEASER' 'GOOGLE_JAVA_FORMAT' 'GROOVY' 'HTML' 'JAVA'
|
||||||
|
'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON' 'JSONC' 'JSX'
|
||||||
|
'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
||||||
|
'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN'
|
||||||
|
'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT'
|
||||||
|
'PYTHON_FLAKE8' 'PYTHON_ISORT' 'PYTHON_MYPY' 'PYTHON_RUFF'
|
||||||
|
'R' 'RAKU' 'RENOVATE' 'RUBY' 'RUST_2015'
|
||||||
|
'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT'
|
||||||
|
'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL' 'SQLFLUFF' 'TEKTON'
|
||||||
|
'TERRAFORM_FMT' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX'
|
||||||
|
'TYPESCRIPT_ES' 'TYPESCRIPT_PRETTIER' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
|
@ -265,23 +265,8 @@ TYPESCRIPT_ES_FILE_NAME="${TYPESCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
|
||||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||||
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}"
|
YAML_FILE_NAME="${YAML_CONFIG_FILE:-.yaml-lint.yml}"
|
||||||
|
|
||||||
##################
|
# shellcheck source=/dev/null
|
||||||
# Language array #
|
source /action/lib/globals/languages.sh
|
||||||
##################
|
|
||||||
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT'
|
|
||||||
'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CPP' 'CSHARP' 'CSS' 'DART'
|
|
||||||
'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GITHUB_ACTIONS'
|
|
||||||
'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GO_RELEASER' 'GOOGLE_JAVA_FORMAT' 'GROOVY' 'HTML' 'JAVA'
|
|
||||||
'JAVASCRIPT_ES' 'JAVASCRIPT_PRETTIER' 'JAVASCRIPT_STANDARD' 'JSCPD' 'JSON' 'JSONC' 'JSX'
|
|
||||||
'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
|
||||||
'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN'
|
|
||||||
'PHP_PSALM' 'POWERSHELL' 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT'
|
|
||||||
'PYTHON_FLAKE8' 'PYTHON_ISORT' 'PYTHON_MYPY' 'PYTHON_RUFF'
|
|
||||||
'R' 'RAKU' 'RENOVATE' 'RUBY' 'RUST_2015'
|
|
||||||
'RUST_2018' 'RUST_2021' 'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT'
|
|
||||||
'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL' 'SQLFLUFF' 'TEKTON'
|
|
||||||
'TERRAFORM_FMT' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX'
|
|
||||||
'TYPESCRIPT_ES' 'TYPESCRIPT_PRETTIER' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# Array of changed files #
|
# Array of changed files #
|
||||||
|
|
|
@ -471,6 +471,7 @@ control "super-linter-validate-files" do
|
||||||
"/action/lib/functions/updateSSL.sh",
|
"/action/lib/functions/updateSSL.sh",
|
||||||
"/action/lib/functions/validation.sh",
|
"/action/lib/functions/validation.sh",
|
||||||
"/action/lib/functions/worker.sh",
|
"/action/lib/functions/worker.sh",
|
||||||
|
"/action/lib/globals/languages.sh",
|
||||||
"/action/lib/.automation/actionlint.yml",
|
"/action/lib/.automation/actionlint.yml",
|
||||||
"/action/lib/.automation/.ansible-lint.yml",
|
"/action/lib/.automation/.ansible-lint.yml",
|
||||||
"/action/lib/.automation/.arm-ttk.psd1",
|
"/action/lib/.automation/.arm-ttk.psd1",
|
||||||
|
|
|
@ -4,8 +4,6 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
CREATE_LOG_FILE=false
|
|
||||||
# Default log level
|
# Default log level
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
LOG_LEVEL="DEBUG"
|
LOG_LEVEL="DEBUG"
|
||||||
|
|
|
@ -10,9 +10,6 @@ LOG_LEVEL="DEBUG"
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "lib/functions/log.sh"
|
source "lib/functions/log.sh"
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
CREATE_LOG_FILE=false
|
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "lib/functions/detectFiles.sh"
|
source "lib/functions/detectFiles.sh"
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
CREATE_LOG_FILE=false
|
|
||||||
# Default log level
|
# Default log level
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
LOG_LEVEL="DEBUG"
|
LOG_LEVEL="DEBUG"
|
||||||
|
|
31
test/lib/globalsLanguagesTest.sh
Executable file
31
test/lib/globalsLanguagesTest.sh
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# Default log level
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
LOG_LEVEL="DEBUG"
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "lib/functions/log.sh"
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "lib/globals/languages.sh"
|
||||||
|
|
||||||
|
function LanguageArrayNotEmptyTest() {
|
||||||
|
local FUNCTION_NAME
|
||||||
|
FUNCTION_NAME="${FUNCNAME[0]}"
|
||||||
|
info "${FUNCTION_NAME} start"
|
||||||
|
|
||||||
|
if [ ${#LANGUAGE_ARRAY[@]} -gt 0 ]; then
|
||||||
|
debug "Language array is not empty as expected"
|
||||||
|
else
|
||||||
|
fatal "Language array is empty"
|
||||||
|
fi
|
||||||
|
|
||||||
|
notice "${FUNCTION_NAME} PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
LanguageArrayNotEmptyTest
|
|
@ -3,8 +3,6 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
CREATE_LOG_FILE=false
|
|
||||||
# Default log level
|
# Default log level
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
LOG_LEVEL="DEBUG"
|
LOG_LEVEL="DEBUG"
|
||||||
|
|
|
@ -4,8 +4,6 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
CREATE_LOG_FILE=false
|
|
||||||
# Default log level
|
# Default log level
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
LOG_LEVEL="DEBUG"
|
LOG_LEVEL="DEBUG"
|
||||||
|
|
|
@ -4,8 +4,6 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
CREATE_LOG_FILE=false
|
|
||||||
# Default log level
|
# Default log level
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
LOG_LEVEL="DEBUG"
|
LOG_LEVEL="DEBUG"
|
||||||
|
|
Loading…
Reference in a new issue