From 3a5617235cee5b2620bc6145d8125f469c503599 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Wed, 10 Jan 2024 23:54:13 +0100 Subject: [PATCH] feat!: deprecate error_on_missing_exec_bit (#5120) Deprecate the ERROR_ON_MISSING_EXEC_BIT variable to remove a confusing corner case, and to align the BASH_EXEC check to how super-linter handles other linters. --- .github/workflows/ci.yml | 1 - Makefile | 6 ------ README.md | 1 - docs/upgrade-guide.md | 8 ++++++++ lib/functions/validation.sh | 3 +++ lib/functions/worker.sh | 22 +++------------------- lib/linter.sh | 6 ++---- 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b468c9c..1cc455ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,6 @@ jobs: env: ACTIONS_RUNNER_DEBUG: true CREATE_LOG_FILE: true - ERROR_ON_MISSING_EXEC_BIT: true VALIDATE_ALL_CODEBASE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DEFAULT_BRANCH: main diff --git a/Makefile b/Makefile index 55d00186..543a7e26 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,6 @@ test-find: ## Run super-linter on a subdirectory with USE_FIND_ALGORITHM=true docker run \ -e RUN_LOCAL=true \ -e ACTIONS_RUNNER_DEBUG=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e DEFAULT_BRANCH=main \ -e USE_FIND_ALGORITHM=true \ @@ -148,7 +147,6 @@ lint-codebase: ## Lint the entire codebase -e ACTIONS_RUNNER_DEBUG=true \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ -e RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES="default.json,hoge.json" \ -e VALIDATE_ALL_CODEBASE=true \ -v "$(CURDIR):/tmp/lint" \ @@ -166,7 +164,6 @@ lint-subset-files-enable-only-one-type: ## Lint a small subset of files in the c -e ACTIONS_RUNNER_DEBUG=true \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ -e VALIDATE_ALL_CODEBASE=true \ -e VALIDATE_MARKDOWN=true \ -v "$(CURDIR):/tmp/lint" \ @@ -179,7 +176,6 @@ lint-subset-files-enable-expensive-io-checks: ## Lint a small subset of files in -e ACTIONS_RUNNER_DEBUG=true \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ -e VALIDATE_ALL_CODEBASE=true \ -e VALIDATE_ARM=true \ -e VALIDATE_CLOUDFORMATION=true \ @@ -226,7 +222,6 @@ test-default-config-files: ## Test default configuration files loading docker run \ -e RUN_LOCAL=true \ -e ACTIONS_RUNNER_DEBUG=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ -e DEFAULT_BRANCH=main \ -e USE_FIND_ALGORITHM=true \ @@ -240,7 +235,6 @@ test-linters: ## Run the linters test suite -e CHECKOV_FILE_NAME=".checkov-test-linters.yaml" \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ - -e ERROR_ON_MISSING_EXEC_BIT=true \ -e JSCPD_CONFIG_FILE=".jscpd-test-linters.json" \ -e RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES="default.json,hoge.json" \ -e RUN_LOCAL=true \ diff --git a/README.md b/README.md index 82961d16..9163077d 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,6 @@ You can configure super-linter using the following environment variables: | **DOCKERFILE_HADOLINT_FILE_NAME** | `.hadolint.yaml` | Filename for [hadolint configuration](https://github.com/hadolint/hadolint) (ex: `.hadolintlintrc.yaml`) | | **EDITORCONFIG_FILE_NAME** | `.ecrc` | Filename for [editorconfig-checker configuration](https://github.com/editorconfig-checker/editorconfig-checker) | | **ENABLE_GITHUB_ACTIONS_GROUP_TITLE** | `false` if `RUN_LOCAL=true`, `true` otherwise | Flag to enable [GitHub Actions log grouping](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines). | -| **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 error 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/.*`) | | **GITHUB_ACTIONS_CONFIG_FILE** | `actionlint.yml` | Filename for [Actionlint configuration](https://github.com/rhysd/actionlint/blob/main/docs/config.md) (ex: `actionlint.yml`) | diff --git a/docs/upgrade-guide.md b/docs/upgrade-guide.md index 8d555b64..67c6745b 100644 --- a/docs/upgrade-guide.md +++ b/docs/upgrade-guide.md @@ -34,6 +34,14 @@ This section helps you migrate from super-linter `v5` to `v6`. [Customizing static analysis](https://dart.dev/tools/analysis) in the Dart SDK documentation. +### ERROR_ON_MISSING_EXEC_BIT + +- `ERROR_ON_MISSING_EXEC_BIT` has been deprecated to align the + `VALIDATE_BASH_EXEC` check to the other linters, removing a surprising corner + case. If `VALIDATE_BASH_EXEC` is set to `true` and a shell script is not + marked as executable, the script will not pass validation. You can remove the + `ERROR_ON_MISSING_EXEC_BIT` variable from your super-linter configuration. + ### Experimental batch workers - Experimental batch support is deprecated. You can safely remove the diff --git a/lib/functions/validation.sh b/lib/functions/validation.sh index 8cd8420c..db7a9c0a 100755 --- a/lib/functions/validation.sh +++ b/lib/functions/validation.sh @@ -320,6 +320,9 @@ function WarnIfVariableIsSet() { } function ValidateDeprecatedVariables() { + + # The following variables have been deprecated in v6 + WarnIfVariableIsSet "${ERROR_ON_MISSING_EXEC_BIT}" "ERROR_ON_MISSING_EXEC_BIT" WarnIfVariableIsSet "${EXPERIMENTAL_BATCH_WORKER}" "EXPERIMENTAL_BATCH_WORKER" WarnIfVariableIsSet "${VALIDATE_JSCPD_ALL_CODEBASE}" "VALIDATE_JSCPD_ALL_CODEBASE" WarnIfVariableIsSet "${VALIDATE_KOTLIN_ANDROID}" "VALIDATE_KOTLIN_ANDROID" diff --git a/lib/functions/worker.sh b/lib/functions/worker.sh index 54a6e2ad..a96ccc01 100755 --- a/lib/functions/worker.sh +++ b/lib/functions/worker.sh @@ -280,26 +280,10 @@ function LintCodebase() { (("GOOD_TEST_CASES_COUNT++")) if [ ${ERROR_CODE} -ne 0 ]; then - debug "Found errors. Error code: ${ERROR_CODE}, File type: ${FILE_TYPE}, Error on missing exec bit: ${ERROR_ON_MISSING_EXEC_BIT}" - if [[ ${FILE_TYPE} == "BASH_EXEC" ]] && [[ "${ERROR_ON_MISSING_EXEC_BIT}" == "false" ]]; then - ######## - # WARN # - ######## - warn "Warnings found in [${LINTER_NAME}] linter!" - warn "${LINT_CMD}" - else - ######### - # Error # - ######### - error "Found errors in [${LINTER_NAME}] linter!" - error "Error code: ${ERROR_CODE}. Command output:${NC}\n------\n${LINT_CMD}\n------" - # Increment the error count - (("ERRORS_FOUND_${FILE_TYPE}++")) - fi + error "Found errors when running ${LINTER_NAME} on ${FILE}. Error code: ${ERROR_CODE}. File type: ${FILE_TYPE}. Command output:${NC}\n------\n${LINT_CMD}\n------" + # Increment the error count + (("ERRORS_FOUND_${FILE_TYPE}++")) else - ########### - # Success # - ########### info " - File:${F[W]}[${FILE_NAME}]${F[B]} was linted with ${F[W]}[${LINTER_NAME}]${F[B]} successfully" if [ -n "${LINT_CMD}" ]; then info " - Command output:${NC}\n------\n${LINT_CMD}\n------" diff --git a/lib/linter.sh b/lib/linter.sh index 85ad4966..26c864a8 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -420,10 +420,8 @@ debug "TEST_CASE_RUN: ${TEST_CASE_RUN}" ############################################################### # Default Vars that are called in Subs and need to be ignored # ############################################################### -DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors -export DEFAULT_DISABLE_ERRORS # Workaround SC2034 -ERROR_ON_MISSING_EXEC_BIT="${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 +DEFAULT_DISABLE_ERRORS='false' # Default to enabling errors +export DEFAULT_DISABLE_ERRORS # Workaround SC2034 RAW_FILE_ARRAY=() # Array of all files that were changed export RAW_FILE_ARRAY # Workaround SC2034 TEST_CASE_FOLDER='test/linters' # Folder for test cases we should always ignore