mirror of
https://github.com/super-linter/super-linter.git
synced 2024-12-22 04:32:16 -05:00
feat: allow passing custom options to rust clippy (#6094)
Define the RUST_CLIPPY_COMMAND_OPTIONS variable to allow passing arbitrary options to the command that runs RUST_CLIPPY. Fix the ARM test case that just failed because of its apiVersion just expired. Close #4001
This commit is contained in:
parent
dd33b476f8
commit
05d4d4e128
7 changed files with 51 additions and 12 deletions
|
@ -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"
|
||||
},
|
||||
|
|
4
Makefile
4
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 \
|
||||
|
|
|
@ -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`) |
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue