Skip to content

Commit 4099648

Browse files
authored
feat: support passing arguments to java (#6785)
Close #6281
1 parent 4e80084 commit 4099648

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ You can configure Super-linter using the following environment variables:
286286
| **GROOVY_FAILON_LEVEL** | `warning` | npm-groovy-lint failon level. |
287287
| **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. |
288288
| **IGNORE_GITIGNORED_FILES** | `false` | If set to `true`, super-linter will ignore all the files that are ignored by Git. Jscpd and Checkov ignore this variable. Use their include and ignore features to select or ignore the files to lint. |
289+
| **JAVA_COMMAND_ARGS** | not set | 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` |
289290
| **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. |
290291
| **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`) |
291292
| **JSCPD_CONFIG_FILE** | `.jscpd.json` | Filename for JSCPD configuration |

lib/functions/linterCommands.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ if [ -n "${GITLEAKS_LOG_LEVEL:-}" ]; then
151151
fi
152152
if [ -n "${GITLEAKS_COMMAND_OPTIONS:-}" ]; then
153153
export GITLEAKS_COMMAND_OPTIONS
154-
AddOptionsToCommand "LINTER_COMMANDS_ARRAY_GITLEAKS" "${GITLEAKS_COMMAND_OPTIONS}"
154+
if ! AddOptionsToCommand "LINTER_COMMANDS_ARRAY_GITLEAKS" "${GITLEAKS_COMMAND_OPTIONS}"; then
155+
fatal "Error while adding options to GITLEAKS command"
156+
fi
155157
fi
156158
LINTER_COMMANDS_ARRAY_GITLEAKS+=(--source)
157159
LINTER_COMMANDS_ARRAY_GIT_COMMITLINT=(commitlint --verbose --cwd "{}")
@@ -175,6 +177,12 @@ LINTER_COMMANDS_ARRAY_GROOVY=(npm-groovy-lint -c "${GROOVY_LINTER_RULES}" --fail
175177
LINTER_COMMANDS_ARRAY_HTML=(htmlhint --config "${HTML_LINTER_RULES}")
176178
LINTER_COMMANDS_ARRAY_HTML_PRETTIER=("${PRETTIER_COMMAND[@]}")
177179
LINTER_COMMANDS_ARRAY_JAVA=(java -jar /usr/bin/checkstyle -c "${JAVA_LINTER_RULES}")
180+
if [ -n "${JAVA_COMMAND_ARGS:-}" ]; then
181+
export JAVA_COMMAND_ARGS
182+
if ! AddOptionsToCommand "LINTER_COMMANDS_ARRAY_JAVA" "${JAVA_COMMAND_ARGS}"; then
183+
fatal "Error while adding options to JAVA command"
184+
fi
185+
fi
178186
LINTER_COMMANDS_ARRAY_JAVASCRIPT_ES=(eslint -c "${JAVASCRIPT_ES_LINTER_RULES}")
179187
LINTER_COMMANDS_ARRAY_JAVASCRIPT_PRETTIER=("${PRETTIER_COMMAND[@]}")
180188
LINTER_COMMANDS_ARRAY_JSCPD=(jscpd --config "${JSCPD_LINTER_RULES}")

test/lib/linterCommandsTest.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ BASE_LINTER_COMMANDS_ARRAY_GITHUB_ACTIONS=("${LINTER_COMMANDS_ARRAY_GITHUB_ACTIO
6161
BASE_LINTER_COMMANDS_ARRAY_GIT_COMMITLINT=("${LINTER_COMMANDS_ARRAY_GIT_COMMITLINT[@]}")
6262
BASE_LINTER_COMMANDS_ARRAY_GITLEAKS=("${LINTER_COMMANDS_ARRAY_GITLEAKS[@]}")
6363
BASE_LINTER_COMMANDS_ARRAY_GO_MODULES=("${LINTER_COMMANDS_ARRAY_GO_MODULES[@]}")
64+
BASE_LINTER_COMMANDS_ARRAY_JAVA=("${LINTER_COMMANDS_ARRAY_JAVA[@]}")
6465
BASE_LINTER_COMMANDS_ARRAY_JSCPD=("${LINTER_COMMANDS_ARRAY_JSCPD[@]}")
6566
BASE_LINTER_COMMANDS_ARRAY_PERL=("${LINTER_COMMANDS_ARRAY_PERL[@]}")
6667
BASE_LINTER_COMMANDS_ARRAY_RUST_CLIPPY=("${LINTER_COMMANDS_ARRAY_RUST_CLIPPY[@]}")
@@ -408,6 +409,8 @@ CommandOptionsTest() {
408409
# shellcheck disable=SC2034
409410
local GITLEAKS_COMMAND_OPTIONS="${ARGS_TO_ADD}"
410411
# shellcheck disable=SC2034
412+
local JAVA_COMMAND_ARGS="${ARGS_TO_ADD}"
413+
# shellcheck disable=SC2034
411414
local PERL_PERLCRITIC_OPTIONS="${ARGS_TO_ADD}"
412415
# shellcheck disable=SC2034
413416
local RUST_CLIPPY_COMMAND_OPTIONS="${ARGS_TO_ADD}"
@@ -433,6 +436,13 @@ CommandOptionsTest() {
433436
fatal "${FUNCTION_NAME} test failed"
434437
fi
435438

439+
# shellcheck disable=SC2034
440+
local EXPECTED_LINTER_COMMANDS_ARRAY_JAVA=("${BASE_LINTER_COMMANDS_ARRAY_JAVA[@]}")
441+
AddOptionsToCommand "EXPECTED_LINTER_COMMANDS_ARRAY_JAVA" "${JAVA_COMMAND_ARGS}"
442+
if ! AssertArraysElementsContentMatch "LINTER_COMMANDS_ARRAY_JAVA" "EXPECTED_LINTER_COMMANDS_ARRAY_JAVA"; then
443+
fatal "${FUNCTION_NAME} test failed"
444+
fi
445+
436446
# shellcheck disable=SC2034
437447
local EXPECTED_LINTER_COMMANDS_ARRAY_PERL=("${BASE_LINTER_COMMANDS_ARRAY_PERL[@]}")
438448
AddOptionsToCommand "EXPECTED_LINTER_COMMANDS_ARRAY_PERL" "${PERL_PERLCRITIC_OPTIONS}"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy