diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ec72076d..bd4f3b63 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,6 +9,12 @@ "editor.formatOnSaveMode": "file", "editor.wordWrap": "off", "prettier.resolveGlobalModules": true, + "[markdown]": { + "editor.wordWrap": "off" + }, + "[shellscript]": { + "editor.defaultFormatter": "mkhl.shfmt" + }, "[terraform]": { "editor.defaultFormatter": "hashicorp.terraform" }, diff --git a/Makefile b/Makefile index 4fa5789f..65640d6c 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,7 @@ test-git-flags: ## Run super-linter with different git-related flags .PHONY: lint-codebase lint-codebase: ## Lint the entire codebase - docker run \ + docker run $(DOCKER_FLAGS) \ -e CREATE_LOG_FILE=true \ -e RUN_LOCAL=true \ -e LOG_LEVEL=DEBUG \ @@ -263,7 +263,7 @@ lint-codebase: ## Lint the entire codebase # Return an error if there are changes to commit .PHONY: fix-codebase fix-codebase: ## Fix and format the entire codebase - docker run \ + docker run $(DOCKER_FLAGS) \ -e CREATE_LOG_FILE=true \ -e DEFAULT_BRANCH=main \ -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true \ diff --git a/README.md b/README.md index 1b731027..f47750f9 100644 --- a/README.md +++ b/README.md @@ -297,6 +297,7 @@ You can configure Super-linter using the following environment variables: | **PYTHON_RUFF_CONFIG_FILE** | `.ruff.toml` | Filename for [ruff configuration](https://docs.astral.sh/ruff/configuration/) | | **RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES** | not set | Comma-separated filenames for [renovate shareable config preset](https://docs.renovatebot.com/config-presets/) (ex: `default.json`) | | **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`) | +| **RUST_CLIPPY_COMMAND_OPTIONS** | not set | Additional options and arguments to pass to the command when running Clippy. | | **SAVE_SUPER_LINTER_OUTPUT** | `false` | If set to `true`, Super-linter will save its output in the workspace. For more information, see [Super-linter outputs](#super-linter-outputs). | | **SAVE_SUPER_LINTER_SUMMARY** | `false` | If set to `true`, Super-linter will save a summary. For more information, see [Summary outputs](#summary-outputs). | | **SCALAFMT_CONFIG_FILE** | `.scalafmt.conf` | Filename for [scalafmt configuration](https://scalameta.org/scalafmt/docs/configuration.html) (ex: `.scalafmt.conf`) | diff --git a/lib/functions/linterCommands.sh b/lib/functions/linterCommands.sh index 3770aca5..8404200d 100755 --- a/lib/functions/linterCommands.sh +++ b/lib/functions/linterCommands.sh @@ -142,6 +142,10 @@ LINTER_COMMANDS_ARRAY_RUST_2015=(rustfmt --edition 2015) LINTER_COMMANDS_ARRAY_RUST_2018=(rustfmt --edition 2018) LINTER_COMMANDS_ARRAY_RUST_2021=(rustfmt --edition 2021) LINTER_COMMANDS_ARRAY_RUST_CLIPPY=(cargo clippy) +if [ -n "${RUST_CLIPPY_COMMAND_OPTIONS:-}" ]; then + export RUST_CLIPPY_COMMAND_OPTIONS + AddOptionsToCommand "LINTER_COMMANDS_ARRAY_RUST_CLIPPY" "${RUST_CLIPPY_COMMAND_OPTIONS}" +fi LINTER_COMMANDS_ARRAY_SCALAFMT=(scalafmt --config "${SCALAFMT_LINTER_RULES}") LINTER_COMMANDS_ARRAY_SHELL_SHFMT=(shfmt) LINTER_COMMANDS_ARRAY_SNAKEMAKE_LINT=(snakemake --lint -s) diff --git a/test/lib/linterCommandsTest.sh b/test/lib/linterCommandsTest.sh index 2752b0f6..5a05e53c 100755 --- a/test/lib/linterCommandsTest.sh +++ b/test/lib/linterCommandsTest.sh @@ -7,13 +7,6 @@ set -o pipefail # shellcheck source=/dev/null source "test/testUtils.sh" -# Default log level -# shellcheck disable=SC2034 -LOG_LEVEL="DEBUG" - -# shellcheck source=/dev/null -source "lib/functions/log.sh" - # linterCommands.sh needs these # shellcheck source=/dev/null @@ -194,8 +187,18 @@ function InitInputConsumeCommandsTest() { EXPECTED_LINTER_COMMANDS_ARRAY_ANSIBLE=("${BASE_LINTER_COMMANDS_ARRAY_ANSIBLE[@]}" "${INPUT_CONSUME_COMMAND[@]}") # shellcheck disable=SC2034 EXPECTED_LINTER_COMMANDS_ARRAY_GO_MODULES=("${BASE_LINTER_COMMANDS_ARRAY_GO_MODULES[@]}" "${INPUT_CONSUME_COMMAND[@]}") + + # Add some custom options to the Rust command to ensure that they are added before the "input consume" command # shellcheck disable=SC2034 - EXPECTED_LINTER_COMMANDS_ARRAY_RUST_CLIPPY=("${BASE_LINTER_COMMANDS_ARRAY_RUST_CLIPPY[@]}" "${INPUT_CONSUME_COMMAND[@]}") + local RUST_CLIPPY_COMMAND_OPTIONS_ARRAY=("--verbose --help") + RUST_CLIPPY_COMMAND_OPTIONS="${RUST_CLIPPY_COMMAND_OPTIONS_ARRAY[*]}" + + # Source the file again so it accounts for modifications + # shellcheck source=/dev/null + source "lib/functions/linterCommands.sh" + + # shellcheck disable=SC2034 + EXPECTED_LINTER_COMMANDS_ARRAY_RUST_CLIPPY=("${BASE_LINTER_COMMANDS_ARRAY_RUST_CLIPPY[@]}" "${RUST_CLIPPY_COMMAND_OPTIONS_ARRAY[@]}" "${INPUT_CONSUME_COMMAND[@]}") if ! InitInputConsumeCommands; then fatal "Error while initializing GNU parallel input consume commands" @@ -318,6 +321,8 @@ CommandOptionsTest() { KUBERNETES_KUBECONFORM_OPTIONS="-debug -verbose -v" # shellcheck disable=SC2034 PERL_PERLCRITIC_OPTIONS="--gentle --count test/linters/perl/perl_good_1.pl" + # shellcheck disable=SC2034 + RUST_CLIPPY_COMMAND_OPTIONS="--verbose --help" # Source the file again so it accounts for modifications # shellcheck source=/dev/null @@ -327,6 +332,11 @@ CommandOptionsTest() { "${LINTER_COMMANDS_ARRAY_GITHUB_ACTIONS[@]}" "${LINTER_COMMANDS_ARRAY_KUBERNETES_KUBECONFORM[@]}" "${LINTER_COMMANDS_ARRAY_PERL[@]}" + # Rust Clippy is only available in the standard image, so we can't run it when + # testing the slim image + if IsStandardImage; then + "${LINTER_COMMANDS_ARRAY_RUST_CLIPPY[@]}" + fi notice "${FUNCTION_NAME} PASS" } @@ -348,6 +358,14 @@ AddOptionsToCommandTest() { AddOptionsToCommand "TEST_LINTER_COMMANDS_ARRAY_PERL" "--gentle --count test/linters/perl/perl_good_1.pl" "${TEST_LINTER_COMMANDS_ARRAY_PERL[@]}" + # Rust Clippy is only available in the standard image, so we can't run it when + # testing the slim image + if IsStandardImage; then + local TEST_LINTER_COMMANDS_ARRAY_RUST_CLIPPY=("${BASE_LINTER_COMMANDS_ARRAY_RUST_CLIPPY[@]}") + AddOptionsToCommand "TEST_LINTER_COMMANDS_ARRAY_RUST_CLIPPY" "--verbose --help" + "${TEST_LINTER_COMMANDS_ARRAY_RUST_CLIPPY[@]}" + fi + notice "${FUNCTION_NAME} PASS" } diff --git a/test/linters/arm/arm_good_1.json b/test/linters/arm/arm_good_1.json index 3f011abf..e5450130 100644 --- a/test/linters/arm/arm_good_1.json +++ b/test/linters/arm/arm_good_1.json @@ -15,14 +15,14 @@ "location": { "type": "string", "metadata": { - "description": "Location for the resources." + "description": "Location for the resources." } } }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", - "apiVersion": "2022-09-01", + "apiVersion": "2023-01-01", "name": "[concat('store', uniquestring(resourceGroup().id))]", "location": "[parameters('location')]", "kind": "StorageV2", diff --git a/test/testUtils.sh b/test/testUtils.sh index 1bb91b44..a7f317e5 100755 --- a/test/testUtils.sh +++ b/test/testUtils.sh @@ -158,6 +158,16 @@ IsLanguageInSlimImage() { fi } +IsStandardImage() { + if [[ "${IMAGE}" == "standard" ]]; then + debug "This is the standard image" + return 0 + else + debug "This isn't the standard image" + return 1 + fi +} + RemoveTestLeftovers() { local LEFTOVERS_TO_CLEAN=() LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_WORKSPACE}/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/bad/target")