From 5cefb9209f1c5d9cad1d1afb9a7839638d14a4c5 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Tue, 15 Sep 2020 22:40:12 +0200 Subject: [PATCH] Make bash-exec errors or warnings configurable --- README.md | 1 + lib/linter.sh | 2 ++ lib/worker.sh | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0abbce43..3c68d818 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ But if you wish to select or exclude specific linters, we give you full control | **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. | | **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. | | **DOCKERFILE_HADOLINT_FILE_NAME** | `.hadolint.yml` | Filename for [hadolint configuration](https://github.com/hadolint/hadolint) (ex: `.hadolintlintrc.yaml`) | +| **ERROR_ON_MISSING_EXEC_BIT** | `false` | If set to `false`, the `bash-exec` linter will report a warning if a shell script is not executable. If set to `true`, the `bash-exec` linter will report an arror instead. | | **FILTER_REGEX_EXCLUDE** | `none` | Regular expression defining which files will be excluded from linting (ex: `.*src/test.*`) | | **FILTER_REGEX_INCLUDE** | `all` | Regular expression defining which files will be processed by linters (ex: `.*src/.*`) | | **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`) | diff --git a/lib/linter.sh b/lib/linter.sh index 2804c488..84542938 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -257,6 +257,8 @@ DEFAULT_IFS="${IFS}" # Get the Default IFS for up ############################################################### DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors export DEFAULT_DISABLE_ERRORS # Workaround SC2034 +ERROR_ON_MISSING_EXEC_BIT='false' # Default to report a warning if a shell script doesn't have the executable bit set to 1 +export ERROR_ON_MISSING_EXEC_BIT RAW_FILE_ARRAY=() # Array of all files that were changed export RAW_FILE_ARRAY # Workaround SC2034 READ_ONLY_CHANGE_FLAG=0 # Flag set to 1 if files changed are not txt or md diff --git a/lib/worker.sh b/lib/worker.sh index d640e19f..705839eb 100755 --- a/lib/worker.sh +++ b/lib/worker.sh @@ -297,7 +297,7 @@ function LintCodebase() { # Check the shell for errors # ############################## if [ ${ERROR_CODE} -ne 0 ]; then - if [[ ${FILE_TYPE} == "BASH_EXEC" ]]; then + if [[ ${FILE_TYPE} == "BASH_EXEC" ]] && [[ "${ERROR_ON_MISSING_EXEC_BIT}" == "false" ]]; then ######## # WARN # ########