mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 20:52:12 -05:00
91dc6d7234
- Add missing fix mode options for: CLANG_FORMAT, ENV, GOOGLE_JAVA_FORMAT, NATURAL_LANGUAGE, PYTHON_ISORT, RUST_CLIPPY. - Refactor linter tests to make them shorter because there's no need to have big test files. - Refactor 'bad' linter tests for linters that support fix mode so they contain only automatically fixable issues. This is needed to avoid adding another set of 'bad' linter tests for fix mode. - Provide configuration files for linters that support fix mode and for which the default configuration is not suitable to enable fix mode: ansible-lint, ESLint, golangci-lint. - Add a test case for linter commands options for linters that support fix mode, to ensure that fix mode and check-only mode options have been defined. - Refactor the fix mode test to check if linters actually applied modifications to files. - Update documentation about adding test cases for linters that support fix mode. - Don't exit with a fatal error if VALIDATE_xxx is false when testing fix mode because not all linters support fix mode. To enable this, set the new FIX_MODE_TEST_CASE_RUN variable to true.
44 lines
1.2 KiB
Bash
Executable file
44 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
# Default log level
|
|
# shellcheck disable=SC2034
|
|
LOG_LEVEL="DEBUG"
|
|
|
|
# shellcheck source=/dev/null
|
|
source "lib/functions/log.sh"
|
|
|
|
# shellcheck source=/dev/null
|
|
source "test/testUtils.sh"
|
|
|
|
# The sqlfluff command needs this, but we don't want to make this test
|
|
# dependant on other files
|
|
# shellcheck disable=SC2034
|
|
SQLFLUFF_LINTER_RULES="SQLFLUFF_LINTER_RULES"
|
|
|
|
# shellcheck source=/dev/null
|
|
source "lib/globals/linterCommandsOptions.sh"
|
|
|
|
LanguagesWithFixModeTest() {
|
|
local FUNCTION_NAME
|
|
FUNCTION_NAME="${FUNCNAME[0]}"
|
|
info "${FUNCTION_NAME} start"
|
|
|
|
for LANGUAGE in "${LANGUAGES_WITH_FIX_MODE[@]}"; do
|
|
local FIX_MODE_OPTIONS_VARIABLE_NAME="${LANGUAGE}_FIX_MODE_OPTIONS"
|
|
local CHECK_ONLY_MODE_OPTIONS_VARIABLE_NAME="${LANGUAGE}_CHECK_ONLY_MODE_OPTIONS"
|
|
if [[ -v "${FIX_MODE_OPTIONS_VARIABLE_NAME}" ]] ||
|
|
[[ -v "${CHECK_ONLY_MODE_OPTIONS_VARIABLE_NAME}" ]]; then
|
|
debug "${LANGUAGE} has check-only mode or fix mode options as expected"
|
|
else
|
|
fatal "${LANGUAGE} is in the list of languages that support fix mode, but neither check-only mode, nor fix mode options were found"
|
|
fi
|
|
done
|
|
|
|
notice "${FUNCTION_NAME} PASS"
|
|
}
|
|
|
|
LanguagesWithFixModeTest
|