From 4e8371f370390fccd2a4823a28f37faf3d56659a Mon Sep 17 00:00:00 2001 From: liangbowen Date: Sat, 11 Mar 2023 23:47:30 +0800 Subject: [PATCH] add env BASH_SEVERITY to specify minimum severity of errors in shellcheck --- README.md | 1 + lib/linter.sh | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad231f37..37e2cc43 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,7 @@ But if you wish to select or exclude specific linters, we give you full control | **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. | | **ANSIBLE_CONFIG_FILE** | `.ansible-lint.yml` | Filename for [Ansible-lint configuration](https://ansible-lint.readthedocs.io/en/latest/configuring.html#configuration-file) (ex: `.ansible-lint`, `.ansible-lint.yml`) | | **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s), relative to `DEFAULT_WORKSPACE`. Set to `.` to use the top-level of the `DEFAULT_WORKSPACE`. | +| **BASH_SEVERITY** | `style` | Specify the minimum severity of errors to consider in shellcheck. Valid values in order of severity are error, warning, info and style. | | **CREATE_LOG_FILE** | `false` | If set to `true`, it creates the log file. You can set the log filename using the `LOG_FILE` environment variable. | | **CSS_FILE_NAME** | `.stylelintrc.json` | Filename for [Stylelint configuration](https://github.com/stylelint/stylelint) (ex: `.stylelintrc.yml`, `.stylelintrc.yaml`) | | **DEFAULT_BRANCH** | `master` | The name of the repository default branch. | diff --git a/lib/linter.sh b/lib/linter.sh index 2622e0f2..aca74018 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -892,7 +892,12 @@ GetStandardRules "typescript" declare -A LINTER_COMMANDS_ARRAY LINTER_COMMANDS_ARRAY['ANSIBLE']="ansible-lint -c ${ANSIBLE_LINTER_RULES}" LINTER_COMMANDS_ARRAY['ARM']="Import-Module ${ARM_TTK_PSD1} ; \${config} = \$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath" -LINTER_COMMANDS_ARRAY['BASH']="shellcheck --color --external-sources" +if [ -z "${BASH_SEVERITY}" ] +then + LINTER_COMMANDS_ARRAY['BASH']="shellcheck --color --external-sources" +else + LINTER_COMMANDS_ARRAY['BASH']="shellcheck --color --external-sources --severity=${BASH_SEVERITY}" +fi LINTER_COMMANDS_ARRAY['BASH_EXEC']="bash-exec" LINTER_COMMANDS_ARRAY['CLANG_FORMAT']="clang-format --Werror --dry-run" LINTER_COMMANDS_ARRAY['CLOJURE']="clj-kondo --config ${CLOJURE_LINTER_RULES} --lint"