feat: Add JAVA_COMMAND_ARGS support

Fixes #6281
This commit is contained in:
Niel Markwick 2024-10-24 15:39:40 +02:00
parent e69f0364d2
commit daadd98d82
4 changed files with 13 additions and 1 deletions

View file

@ -283,6 +283,7 @@ You can configure Super-linter using the following environment variables:
| **IGNORE_GENERATED_FILES** | `false` | If set to `true`, super-linter will ignore all the files with `@generated` marker but without `@not-generated` marker. Jscpd and Checkov ignore this variable. Use their include and ignore features to select or ignore the files to lint. | | **IGNORE_GENERATED_FILES** | `false` | If set to `true`, super-linter will ignore all the files with `@generated` marker but without `@not-generated` marker. Jscpd and Checkov ignore this variable. Use their include and ignore features to select or ignore the files to lint. |
| **IGNORE_GITIGNORED_FILES** | `false` | If set to `true`, super-linter will ignore all the files that are ignored by Git. Checkov ignores this variable. Use its include and ignore features to select or ignore the files to lint. | | **IGNORE_GITIGNORED_FILES** | `false` | If set to `true`, super-linter will ignore all the files that are ignored by Git. Checkov ignores this variable. Use its include and ignore features to select or ignore the files to lint. |
| **JAVA_FILE_NAME** | `sun_checks.xml` | Filename for [Checkstyle configuration](https://checkstyle.sourceforge.io/config.html). Checkstyle embeds several configuration files, such as `sun_checks.xml`, `google_checks.xml` that you can use without providing your own configuration file. | | **JAVA_FILE_NAME** | `sun_checks.xml` | Filename for [Checkstyle configuration](https://checkstyle.sourceforge.io/config.html). Checkstyle embeds several configuration files, such as `sun_checks.xml`, `google_checks.xml` that you can use without providing your own configuration file. |
| **JAVA_COMMAND_ARGS** | `null` | Additional Java JRE arguments passed to the checkstyle linter that can be used to specify additional configuration parameters via Java properties, such as [Suppression Filter files](https://checkstyle.org/filters/suppressionfilter.html), for example: `-Dorg.checkstyle.sun.suppressionfilter.config=path/to/suppressions.xml` |
| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [ESLint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) | | **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [ESLint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`) |
| **JSCPD_CONFIG_FILE** | `.jscpd.json` | Filename for JSCPD configuration | | **JSCPD_CONFIG_FILE** | `.jscpd.json` | Filename for JSCPD configuration |
| **KUBERNETES_KUBECONFORM_OPTIONS** | `null` | Additional arguments to pass to the command-line when running **Kubernetes Kubeconform** (Example: --ignore-missing-schemas) | | **KUBERNETES_KUBECONFORM_OPTIONS** | `null` | Additional arguments to pass to the command-line when running **Kubernetes Kubeconform** (Example: --ignore-missing-schemas) |

View file

@ -86,7 +86,13 @@ LINTER_COMMANDS_ARRAY_GRAPHQL_PRETTIER=("${PRETTIER_COMMAND[@]}")
LINTER_COMMANDS_ARRAY_GROOVY=(npm-groovy-lint -c "${GROOVY_LINTER_RULES}" --failon warning --no-insight) LINTER_COMMANDS_ARRAY_GROOVY=(npm-groovy-lint -c "${GROOVY_LINTER_RULES}" --failon warning --no-insight)
LINTER_COMMANDS_ARRAY_HTML=(htmlhint --config "${HTML_LINTER_RULES}") LINTER_COMMANDS_ARRAY_HTML=(htmlhint --config "${HTML_LINTER_RULES}")
LINTER_COMMANDS_ARRAY_HTML_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_HTML_PRETTIER=("${PRETTIER_COMMAND[@]}")
LINTER_COMMANDS_ARRAY_JAVA=(java -jar /usr/bin/checkstyle -c "${JAVA_LINTER_RULES}") # Java checkstyle linter needs additional args passed _before_ the -jar arg
LINTER_COMMANDS_ARRAY_JAVA=(java)
if [ "${JAVA_COMMAND_ARGS}" != "null" ] && [ -n "${JAVA_COMMAND_ARGS}" ]; then
export JAVA_COMMAND_ARGS
AddOptionsToCommand "LINTER_COMMANDS_ARRAY_JAVA" "${JAVA_COMMAND_ARGS}"
fi
LINTER_COMMANDS_ARRAY_JAVA+=(-jar /usr/bin/checkstyle -c "${JAVA_LINTER_RULES}")
LINTER_COMMANDS_ARRAY_JAVASCRIPT_ES=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}") LINTER_COMMANDS_ARRAY_JAVASCRIPT_ES=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}")
LINTER_COMMANDS_ARRAY_JAVASCRIPT_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_JAVASCRIPT_PRETTIER=("${PRETTIER_COMMAND[@]}")
LINTER_COMMANDS_ARRAY_JAVASCRIPT_STANDARD=(standard "${JAVASCRIPT_STANDARD_LINTER_RULES}") LINTER_COMMANDS_ARRAY_JAVASCRIPT_STANDARD=(standard "${JAVASCRIPT_STANDARD_LINTER_RULES}")

View file

@ -37,6 +37,8 @@ HTML_FILE_NAME=".htmlhintrc"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
JAVA_FILE_NAME="${JAVA_FILE_NAME:-sun_checks.xml}" JAVA_FILE_NAME="${JAVA_FILE_NAME:-sun_checks.xml}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
JAVA_COMMAND_ARGS="${JAVA_COMMAND_ARGS:-null}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
JAVASCRIPT_ES_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" JAVASCRIPT_ES_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
JAVASCRIPT_STANDARD_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}" JAVASCRIPT_STANDARD_FILE_NAME="${JAVASCRIPT_ES_CONFIG_FILE:-.eslintrc.yml}"

View file

@ -340,6 +340,8 @@ CommandOptionsTest() {
# shellcheck disable=SC2034 # shellcheck disable=SC2034
GITHUB_ACTIONS_COMMAND_ARGS="-color -debug -verbose -version" GITHUB_ACTIONS_COMMAND_ARGS="-color -debug -verbose -version"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
JAVA_COMMAND_ARGS="-Dproperty1=value1 -version"
# shellcheck disable=SC2034
KUBERNETES_KUBECONFORM_OPTIONS="-debug -verbose -v" KUBERNETES_KUBECONFORM_OPTIONS="-debug -verbose -v"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
PERL_PERLCRITIC_OPTIONS="--gentle --count test/linters/perl/perl_good_1.pl" PERL_PERLCRITIC_OPTIONS="--gentle --count test/linters/perl/perl_good_1.pl"
@ -352,6 +354,7 @@ CommandOptionsTest() {
# Try running the commands # Try running the commands
"${LINTER_COMMANDS_ARRAY_GITHUB_ACTIONS[@]}" "${LINTER_COMMANDS_ARRAY_GITHUB_ACTIONS[@]}"
"${LINTER_COMMANDS_ARRAY_JAVA[@]}"
"${LINTER_COMMANDS_ARRAY_KUBERNETES_KUBECONFORM[@]}" "${LINTER_COMMANDS_ARRAY_KUBERNETES_KUBECONFORM[@]}"
"${LINTER_COMMANDS_ARRAY_PERL[@]}" "${LINTER_COMMANDS_ARRAY_PERL[@]}"
# Rust Clippy is only available in the standard image, so we can't run it when # Rust Clippy is only available in the standard image, so we can't run it when