diff --git a/.github/linters/.jscpd.json b/.github/linters/.jscpd.json index 099a72d3..cfdc0863 100644 --- a/.github/linters/.jscpd.json +++ b/.github/linters/.jscpd.json @@ -11,6 +11,9 @@ "**/test/linters/coffeescript", "**/test/linters/css", "**/test/linters/css_prettier", + "**/test/linters/dotnet_sln_format_analyzers", + "**/test/linters/dotnet_sln_format_style", + "**/test/linters/dotnet_sln_format_whitespace", "**/test/linters/html", "**/test/linters/javascript_es", "**/test/linters/javascript_prettier", diff --git a/.gitignore b/.gitignore index d1c77707..1e36fc2b 100644 --- a/.gitignore +++ b/.gitignore @@ -90,6 +90,8 @@ test/reports .lintr test/linters/rust_clippy/**/Cargo.lock test/linters/rust_clippy/**/target +test/linters/**/src/bin +test/linters/**/src/obj # Super-linter ouputs super-linter-output/ diff --git a/Makefile b/Makefile index 31ee6436..e49e4e81 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: info docker test ## Run all targets. .PHONY: test -test: info validate-container-image-labels docker-build-check docker-dev-container-build-check test-lib inspec lint-codebase fix-codebase test-default-config-files test-actions-runner-debug test-actions-steps-debug test-runner-debug test-find lint-subset-files test-custom-ssl-cert test-non-default-workdir test-git-flags test-non-default-home-directory test-git-initial-commit test-git-merge-commit-push test-log-level test-use-find-and-ignore-gitignored-files test-linters-expect-failure-log-level-notice test-bash-exec-library-expect-success test-bash-exec-library-expect-failure test-save-super-linter-output test-save-super-linter-output-custom-path test-save-super-linter-custom-summary test-custom-gitleaks-log-level test-linters test-linters-fix-mode ## Run the test suite +test: info validate-container-image-labels docker-build-check docker-dev-container-build-check test-lib inspec lint-codebase fix-codebase test-default-config-files test-actions-runner-debug test-actions-steps-debug test-runner-debug test-find lint-subset-files test-custom-ssl-cert test-non-default-workdir test-git-flags test-non-default-home-directory test-git-initial-commit test-git-merge-commit-push test-log-level test-use-find-and-ignore-gitignored-files test-linters-expect-failure-log-level-notice test-bash-exec-library-expect-success test-bash-exec-library-expect-failure test-save-super-linter-output test-save-super-linter-output-custom-path test-save-super-linter-custom-summary test-custom-gitleaks-log-level test-dont-save-super-linter-log-file test-dont-save-super-linter-output test-linters test-linters-fix-mode ## Run the test suite # if this session isn't interactive, then we don't want to allocate a # TTY, which would fail, but if it is interactive, we do want to attach @@ -532,6 +532,20 @@ test-custom-gitleaks-log-level: ## Run super-linter with a custom Gitleaks log l "run_test_case_gitleaks_custom_log_level" \ "$(IMAGE)" +.PHONY: test-dont-save-super-linter-log-file +test-dont-save-super-linter-log-file: ## Run super-linter without saving the Super-linter log file + $(CURDIR)/test/run-super-linter-tests.sh \ + $(SUPER_LINTER_TEST_CONTAINER_URL) \ + "run_test_case_dont_save_super_linter_log_file" \ + "$(IMAGE)" + +.PHONY: test-dont-save-super-linter-output +test-dont-save-super-linter-output: ## Run super-linter without saving Super-linter output files + $(CURDIR)/test/run-super-linter-tests.sh \ + $(SUPER_LINTER_TEST_CONTAINER_URL) \ + "run_test_case_dont_save_super_linter_output" \ + "$(IMAGE)" + .PHONY: docker-dev-container-build-check ## Run Docker build checks against the dev-container image docker-dev-container-build-check: DOCKER_BUILDKIT=1 docker buildx build --check \ diff --git a/README.md b/README.md index 6435638e..10adb6d2 100644 --- a/README.md +++ b/README.md @@ -51,64 +51,65 @@ Here are some notable Super-linter features: Super-linter supports the following tools: -| Language | Linters | Formatters | -| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | See YAML and Python formatters | -| **Amazon States Language** | [ASL Validator](https://github.com/ChristopheBougere/asl-validator) | See JSON formatters | -| **AWS CloudFormation templates** | [AWS CloudFormation Linter (cfn-lint)](https://github.com/aws-cloudformation/cfn-lint), [Checkov](https://www.checkov.io/) | See YAML formatters | -| **Azure Resource Manager (ARM)** | [Azure Resource Manager Template Toolkit (arm-ttk)](https://github.com/azure/arm-ttk), [Checkov](https://www.checkov.io/) | See JSON formatters | -| **C**, **C++++** | [cpp-lint](https://github.com/cpplint/cpplint) | [clang-format](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) | -| **C#** | | [dotnet format whitespace command](https://github.com/dotnet/format) | -| **CSS**, **SCSS**, **Sass** | [stylelint](https://stylelint.io/) | [Prettier](https://prettier.io/) | -| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | | -| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | | -| **Copy/paste detection** | [jscpd](https://github.com/kucherenko/jscpd) | N/A | -| **Dart** | [dart analyze command](https://dart.dev/guides/language/analysis-options) | | -| **Dockerfile** | [Haskell Dockerfile Linter (Hadolint)](https://github.com/hadolint/hadolint), [Checkov](https://www.checkov.io/) | | -| **EditorConfig** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | | -| **.env** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | | -| **Gherkin** | [gherkin-lint](https://github.com/vsiakka/gherkin-lint) | | -| **GitHub Actions** | [actionlint](https://github.com/rhysd/actionlint) | See YAML formatters | -| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | | -| **GoReleaser** | [GoReleaser](https://github.com/goreleaser/goreleaser) | See YAML formatters | -| **GraphQL** | | [Prettier](https://prettier.io/) | -| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | | -| **Helm charts** | [Checkov](https://www.checkov.io/) | See YAML formatters | -| **HTML** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | [Prettier](https://prettier.io/) | -| **Java** | [checkstyle](https://checkstyle.org) | [google-java-format](https://github.com/google/google-java-format) | -| **JavaScript** | [ESLint](https://eslint.org/), [standard js](https://standardjs.com/) | [Prettier](https://prettier.io/) | -| **JSON** | [eslint-plugin-jsonc (configured for JSON)](https://www.npmjs.com/package/eslint-plugin-jsonc) (default), [eslint-plugin-json](https://www.npmjs.com/package/eslint-plugin-json) | [Prettier](https://prettier.io/) | -| **JSONC**, **JSON5** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) | | -| **JSX**, **TSX** | [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y), [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) | [Prettier](https://prettier.io/) | -| **Kubernetes** | [kubeconform](https://github.com/yannh/kubeconform), [Checkov](https://www.checkov.io/) | See YAML formatters | -| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | | -| **LaTeX** | [ChkTex](https://www.nongnu.org/chktex/) | | -| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | | -| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli) | [Prettier](https://prettier.io/) | -| **Natural language** | [textlint](https://textlint.github.io/) | N/A | -| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | See YAML formatters | -| **Perl** | [perlcritic](https://metacpan.org/pod/Perl::Critic) | | -| **PHP** | [PHP built-in linter](https://www.php.net/manual/en/features.commandline.options.php), [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer), [PHPStan](https://phpstan.org/), [Psalm](https://psalm.dev/) | | -| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | -| **Protocol Buffers (Protobuf)** | [protolint](https://github.com/yoheimuta/protolint) | | -| **Python3** | [pylint](https://pylint.pycqa.org/), [flake8](https://flake8.pycqa.org/en/latest/), [isort](https://pypi.org/project/isort/), [ruff](https://github.com/astral-sh/ruff) | [black](https://github.com/psf/black) | -| **R** | [lintr](https://github.com/jimhester/lintr) | | -| **Raku** | [Raku](https://raku.org) | | -| **Renovate** | [renovate-config-validator](https://docs.renovatebot.com/config-validation/) | N/A | -| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | -| **Rust** | [Rustfmt](https://github.com/rust-lang/rustfmt), [Clippy](https://github.com/rust-lang/rust-clippy) | | -| **Scala** | | [scalafmt](https://github.com/scalameta/scalafmt) | -| **Secrets** | [GitLeaks](https://github.com/zricethezav/gitleaks) | N/A | -| **Shell** | [ShellCheck](https://github.com/koalaman/shellcheck), `executable bit check` | [shfmt](https://github.com/mvdan/sh) | -| **Snakemake** | [snakemake --lint](https://snakemake.readthedocs.io/en/stable/snakefiles/writing_snakefiles.html#best-practices) | [snakefmt](https://github.com/snakemake/snakefmt/) | -| **SQL** | [sqlfluff](https://github.com/sqlfluff/sqlfluff) | | -| **Tekton** | [tekton-lint](https://github.com/IBM/tekton-lint) | See YAML formatters | -| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) , [terrascan](https://github.com/accurics/terrascan), [Checkov](https://www.checkov.io/) | [terraform fmt](https://developer.hashicorp.com/terraform/cli/commands/fmt) | -| **Terragrunt** | [terragrunt](https://github.com/gruntwork-io/terragrunt) | N/A | -| **TypeScript** | [ESLint](https://eslint.org/), [standard js](https://standardjs.com/) | [Prettier](https://prettier.io/) | -| **Vue** | | [Prettier](https://prettier.io/) | -| **XML** | [LibXML](http://xmlsoft.org/) | | -| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | [Prettier](https://prettier.io/) | +| Language | Linters | Formatters | +| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | +| **Ansible** | [ansible-lint](https://github.com/ansible/ansible-lint) | See YAML and Python formatters | +| **Amazon States Language** | [ASL Validator](https://github.com/ChristopheBougere/asl-validator) | See JSON formatters | +| **AWS CloudFormation templates** | [AWS CloudFormation Linter (cfn-lint)](https://github.com/aws-cloudformation/cfn-lint), [Checkov](https://www.checkov.io/) | See YAML formatters | +| **Azure Resource Manager (ARM)** | [Azure Resource Manager Template Toolkit (arm-ttk)](https://github.com/azure/arm-ttk), [Checkov](https://www.checkov.io/) | See JSON formatters | +| **C**, **C++++** | [cpp-lint](https://github.com/cpplint/cpplint) | [clang-format](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) | +| **C#** | See Dotnet solutions | [dotnet format whitespace command](https://github.com/dotnet/format) | +| **CSS**, **SCSS**, **Sass** | [stylelint](https://stylelint.io/) | [Prettier](https://prettier.io/) | +| **Clojure** | [clj-kondo](https://github.com/borkdude/clj-kondo) | | +| **CoffeeScript** | [coffeelint](https://coffeelint.github.io/) | | +| **Copy/paste detection** | [jscpd](https://github.com/kucherenko/jscpd) | N/A | +| **Dart** | [dart analyze command](https://dart.dev/guides/language/analysis-options) | | +| **Dockerfile** | [Haskell Dockerfile Linter (Hadolint)](https://github.com/hadolint/hadolint), [Checkov](https://www.checkov.io/) | | +| **Dotnet (.NET) solutions (sln)** | [dotnet format command](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format): analyzers, style subcommands. | [dotnet format command](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format): whitespace subcommand. | +| **EditorConfig** | [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) | | +| **.env** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) | | +| **Gherkin** | [gherkin-lint](https://github.com/vsiakka/gherkin-lint) | | +| **GitHub Actions** | [actionlint](https://github.com/rhysd/actionlint) | See YAML formatters | +| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | | +| **GoReleaser** | [GoReleaser](https://github.com/goreleaser/goreleaser) | See YAML formatters | +| **GraphQL** | | [Prettier](https://prettier.io/) | +| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | | +| **Helm charts** | [Checkov](https://www.checkov.io/) | See YAML formatters | +| **HTML** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | [Prettier](https://prettier.io/) | +| **Java** | [checkstyle](https://checkstyle.org) | [google-java-format](https://github.com/google/google-java-format) | +| **JavaScript** | [ESLint](https://eslint.org/), [standard js](https://standardjs.com/) | [Prettier](https://prettier.io/) | +| **JSON** | [eslint-plugin-jsonc (configured for JSON)](https://www.npmjs.com/package/eslint-plugin-jsonc) (default), [eslint-plugin-json](https://www.npmjs.com/package/eslint-plugin-json) | [Prettier](https://prettier.io/) | +| **JSONC**, **JSON5** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) | | +| **JSX**, **TSX** | [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y), [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) | [Prettier](https://prettier.io/) | +| **Kubernetes** | [kubeconform](https://github.com/yannh/kubeconform), [Checkov](https://www.checkov.io/) | See YAML formatters | +| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) | | +| **LaTeX** | [ChkTex](https://www.nongnu.org/chktex/) | | +| **Lua** | [luacheck](https://github.com/luarocks/luacheck) | | +| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli) | [Prettier](https://prettier.io/) | +| **Natural language** | [textlint](https://textlint.github.io/) | N/A | +| **OpenAPI** | [spectral](https://github.com/stoplightio/spectral) | See YAML formatters | +| **Perl** | [perlcritic](https://metacpan.org/pod/Perl::Critic) | | +| **PHP** | [PHP built-in linter](https://www.php.net/manual/en/features.commandline.options.php), [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer), [PHPStan](https://phpstan.org/), [Psalm](https://psalm.dev/) | | +| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) | | +| **Protocol Buffers (Protobuf)** | [protolint](https://github.com/yoheimuta/protolint) | | +| **Python3** | [pylint](https://pylint.pycqa.org/), [flake8](https://flake8.pycqa.org/en/latest/), [isort](https://pypi.org/project/isort/), [ruff](https://github.com/astral-sh/ruff) | [black](https://github.com/psf/black) | +| **R** | [lintr](https://github.com/jimhester/lintr) | | +| **Raku** | [Raku](https://raku.org) | | +| **Renovate** | [renovate-config-validator](https://docs.renovatebot.com/config-validation/) | N/A | +| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) | | +| **Rust** | [Clippy](https://github.com/rust-lang/rust-clippy) | [Rustfmt](https://github.com/rust-lang/rustfmt) | +| **Scala** | | [scalafmt](https://github.com/scalameta/scalafmt) | +| **Secrets** | [GitLeaks](https://github.com/zricethezav/gitleaks) | N/A | +| **Shell** | [ShellCheck](https://github.com/koalaman/shellcheck), `executable bit check` | [shfmt](https://github.com/mvdan/sh) | +| **Snakemake** | [snakemake --lint](https://snakemake.readthedocs.io/en/stable/snakefiles/writing_snakefiles.html#best-practices) | [snakefmt](https://github.com/snakemake/snakefmt/) | +| **SQL** | [sqlfluff](https://github.com/sqlfluff/sqlfluff) | | +| **Tekton** | [tekton-lint](https://github.com/IBM/tekton-lint) | See YAML formatters | +| **Terraform** | [tflint](https://github.com/terraform-linters/tflint) , [terrascan](https://github.com/accurics/terrascan), [Checkov](https://www.checkov.io/) | [terraform fmt](https://developer.hashicorp.com/terraform/cli/commands/fmt) | +| **Terragrunt** | [terragrunt](https://github.com/gruntwork-io/terragrunt) | N/A | +| **TypeScript** | [ESLint](https://eslint.org/), [standard js](https://standardjs.com/) | [Prettier](https://prettier.io/) | +| **Vue** | | [Prettier](https://prettier.io/) | +| **XML** | [LibXML](http://xmlsoft.org/) | | +| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) | [Prettier](https://prettier.io/) | ## Get started @@ -183,10 +184,11 @@ Super-Linter provides several variants: - `standard`: `super-linter/super-linter@[VERSION]`: includes all supported linters. - `slim`: `super-linter/super-linter/slim@[VERSION]`: includes all supported linters except: - - `rust` linters - - `armttk` linters - - `pwsh` linters - - `c#` linters + - Rustfmt + - Rust Clippy + - Azure Resource Manager Template Toolkit (arm-ttk) + - PSScriptAnalyzer + - `dotnet` (.NET) commands and subcommands ## Configure Super-linter @@ -217,6 +219,9 @@ You can configure Super-linter using the following environment variables: | **FIX_CSHARP** | `false` | Option to enable fix mode for `CSHARP`. | | **FIX_CSS_PRETTIER** | `true` | Flag to enable or disable the formatting of CSS, Sass, and SCSS files with Prettier. | | **FIX_CSS** | `false` | Option to enable fix mode for `CSS`. | +| **FIX_DOTNET_SLN_FORMAT_ANALYZERS** | `false` | Option to enable or disable fix mode for Dotnet solutions. | +| **FIX_DOTNET_SLN_FORMAT_STYLE** | `false` | Option to enable or disable fix mode for Dotnet solutions. | +| **FIX_DOTNET_SLN_FORMAT_WHITESPACE** | `true` | Option to enable or disable fix mode for Dotnet solutions. | | **FIX_ENV** | `false` | Option to enable fix mode for `ENV`. | | **FIX_GO_MODULES** | `false` | Option to enable fix mode for `GO_MODULES`. | | **FIX_GO** | `false` | Option to enable fix mode for `GO`. | @@ -323,6 +328,9 @@ You can configure Super-linter using the following environment variables: | **VALIDATE_CSS_PRETTIER** | `true` | Flag to enable or disable checking the formatting of CSS, Sass, and SCSS files with Prettier. | | **VALIDATE_DART** | `true` | Flag to enable or disable the linting process of the Dart language. | | **VALIDATE_DOCKERFILE_HADOLINT** | `true` | Flag to enable or disable the linting process of the Docker language. | +| **VALIDATE_DOTNET_SLN_FORMAT_ANALYZERS** | `true` | Option to enable or disable the linting process of Dotnet solutions. | +| **VALIDATE_DOTNET_SLN_FORMAT_STYLE** | `true` | Option to enable or disable the linting process of Dotnet solutions. | +| **VALIDATE_DOTNET_SLN_FORMAT_WHITESPACE** | `true` | Option to enable or disable the linting process of Dotnet solutions. | | **VALIDATE_EDITORCONFIG** | `true` | Flag to enable or disable the linting process with the EditorConfig. | | **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the ENV language. | | **VALIDATE_GHERKIN** | `true` | Flag to enable or disable the linting process of the Gherkin language. | diff --git a/docs/add-new-linter.md b/docs/add-new-linter.md index 154d0d08..07c0b57c 100644 --- a/docs/add-new-linter.md +++ b/docs/add-new-linter.md @@ -15,7 +15,8 @@ new tool, it should include: If the linter supports fix mode, the test case supposed to fail validation should only contain violations that the fix mode can automatically fix. Avoid test cases that fail only because of syntax errors, when possible. - 4. If the linter supports check-only mode or fix mode, add the `` + 4. Update expected summary reports: `test/data/super-linter-summary`. + 5. If the linter supports check-only mode or fix mode, add the `` to the `LANGUAGES_WITH_FIX_MODE` array in `test/testUtils.sh` - Update the test suite to check for installed packages, the commands that your new tool needs in the `PATH`, and the expected version command: diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index 32633953..86126e47 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -517,6 +517,10 @@ BuildFileArrays() { echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GRAPHQL_PRETTIER" elif [ "${FILE_TYPE}" == "vue" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-VUE_PRETTIER" + elif [ "${FILE_TYPE}" == "sln" ]; then + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-DOTNET_SLN_FORMAT_ANALYZERS" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-DOTNET_SLN_FORMAT_STYLE" + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-DOTNET_SLN_FORMAT_WHITESPACE" elif [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-YAML" echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-YAML_PRETTIER" diff --git a/lib/functions/linterCommands.sh b/lib/functions/linterCommands.sh index 62097cd5..b25a3328 100755 --- a/lib/functions/linterCommands.sh +++ b/lib/functions/linterCommands.sh @@ -14,6 +14,7 @@ source /action/lib/globals/linterCommandsOptions.sh # These commands are reused across several languages PRETTIER_COMMAND=(prettier) +DOTNET_FORMAT_COMMAND=(dotnet format) LINTER_COMMANDS_ARRAY_ANSIBLE=(ansible-lint -c "${ANSIBLE_LINTER_RULES}") LINTER_COMMANDS_ARRAY_ARM=(pwsh -NoProfile -NoLogo -Command "\"Import-Module ${ARM_TTK_PSD1} ; \\\${config} = \\\$(Import-PowerShellDataFile -Path ${ARM_LINTER_RULES}) ; Test-AzTemplate @config -TemplatePath '{}'; if (\\\${Error}.Count) { exit 1 }\"") @@ -44,11 +45,14 @@ LINTER_COMMANDS_ARRAY_CLOJURE=(clj-kondo --config "${CLOJURE_LINTER_RULES}" --li LINTER_COMMANDS_ARRAY_CLOUDFORMATION=(cfn-lint --config-file "${CLOUDFORMATION_LINTER_RULES}") LINTER_COMMANDS_ARRAY_COFFEESCRIPT=(coffeelint -f "${COFFEESCRIPT_LINTER_RULES}") LINTER_COMMANDS_ARRAY_CPP=(cpplint) -LINTER_COMMANDS_ARRAY_CSHARP=(dotnet format whitespace --folder --exclude / --include "{/}") +LINTER_COMMANDS_ARRAY_CSHARP=("${DOTNET_FORMAT_COMMAND[@]}" whitespace --folder --exclude / --include "{/}") LINTER_COMMANDS_ARRAY_CSS=(stylelint --config "${CSS_LINTER_RULES}") LINTER_COMMANDS_ARRAY_CSS_PRETTIER=("${PRETTIER_COMMAND[@]}") LINTER_COMMANDS_ARRAY_DART=(dart analyze --fatal-infos --fatal-warnings) LINTER_COMMANDS_ARRAY_DOCKERFILE_HADOLINT=(hadolint -c "${DOCKERFILE_HADOLINT_LINTER_RULES}") +LINTER_COMMANDS_ARRAY_DOTNET_SLN_FORMAT_ANALYZERS=("${DOTNET_FORMAT_COMMAND[@]}" analyzers) +LINTER_COMMANDS_ARRAY_DOTNET_SLN_FORMAT_STYLE=("${DOTNET_FORMAT_COMMAND[@]}" style) +LINTER_COMMANDS_ARRAY_DOTNET_SLN_FORMAT_WHITESPACE=("${DOTNET_FORMAT_COMMAND[@]}" whitespace) LINTER_COMMANDS_ARRAY_EDITORCONFIG=(editorconfig-checker -config "${EDITORCONFIG_LINTER_RULES}") LINTER_COMMANDS_ARRAY_ENV=(dotenv-linter) LINTER_COMMANDS_ARRAY_GITHUB_ACTIONS=(actionlint -config-file "${GITHUB_ACTIONS_LINTER_RULES}") diff --git a/lib/functions/worker.sh b/lib/functions/worker.sh index a56eb991..c3e31807 100755 --- a/lib/functions/worker.sh +++ b/lib/functions/worker.sh @@ -103,6 +103,9 @@ function LintCodebase() { [[ "${FILE_TYPE}" == "BASH_EXEC" ]] || [[ "${FILE_TYPE}" == "CLOJURE" ]] || [[ "${FILE_TYPE}" == "CSHARP" ]] || + [[ "${FILE_TYPE}" == "DOTNET_SLN_FORMAT_ANALYZERS" ]] || + [[ "${FILE_TYPE}" == "DOTNET_SLN_FORMAT_STYLE" ]] || + [[ "${FILE_TYPE}" == "DOTNET_SLN_FORMAT_WHITESPACE" ]] || [[ "${FILE_TYPE}" == "GITLEAKS" ]] || [[ "${FILE_TYPE}" == "GO_MODULES" ]] || [[ "${FILE_TYPE}" == "JSCPD" ]] || diff --git a/lib/globals/languages.sh b/lib/globals/languages.sh index dcf9d8f0..0b1691d3 100755 --- a/lib/globals/languages.sh +++ b/lib/globals/languages.sh @@ -6,7 +6,12 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT' 'CSS' "CSS_PRETTIER" 'DART' - 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' + 'DOCKERFILE_HADOLINT' + "DOTNET_SLN_FORMAT_ANALYZERS" + "DOTNET_SLN_FORMAT_STYLE" + "DOTNET_SLN_FORMAT_WHITESPACE" + 'EDITORCONFIG' + 'ENV' 'GITHUB_ACTIONS' 'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GO_RELEASER' 'GOOGLE_JAVA_FORMAT' "GRAPHQL_PRETTIER" diff --git a/lib/globals/linterCommandsOptions.sh b/lib/globals/linterCommandsOptions.sh index a143cdcf..2b5e0d1c 100755 --- a/lib/globals/linterCommandsOptions.sh +++ b/lib/globals/linterCommandsOptions.sh @@ -6,13 +6,17 @@ # "check only" mode options for linters that that we reuse across several languages PRETTIER_CHECK_ONLY_MODE_OPTIONS=(--check) RUSTFMT_CHECK_ONLY_MODE_OPTIONS=(--check) +DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--verify-no-changes) # Define configuration options to enable "check only" mode. # Some linters and formatters only support a "check only" mode so there's no # need to define a "check only" mode option for those. CLANG_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--dry-run) -CSHARP_CHECK_ONLY_MODE_OPTIONS=(--verify-no-changes) +CSHARP_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}") CSS_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") +DOTNET_SLN_FORMAT_ANALYZERS_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}") +DOTNET_SLN_FORMAT_STYLE_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}") +DOTNET_SLN_FORMAT_WHITESPACE_CHECK_ONLY_MODE_OPTIONS=("${DOTNET_FORMAT_CHECK_ONLY_MODE_OPTIONS[@]}") GOOGLE_JAVA_FORMAT_CHECK_ONLY_MODE_OPTIONS=(--dry-run --set-exit-if-changed) GRAPHQL_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") HTML_PRETTIER_CHECK_ONLY_MODE_OPTIONS=("${PRETTIER_CHECK_ONLY_MODE_OPTIONS[@]}") diff --git a/lib/linter.sh b/lib/linter.sh index a05e99c3..b72f3810 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -582,8 +582,18 @@ UpdateLoopsForImage() { ############################################# # Need to remove linters for the slim image # ############################################# - REMOVE_ARRAY=("ARM" "CSHARP" "POWERSHELL" "RUST_2015" "RUST_2018" - "RUST_2021" "RUST_CLIPPY") + REMOVE_ARRAY=( + "ARM" + "CSHARP" + "DOTNET_SLN_FORMAT_ANALYZERS" + "DOTNET_SLN_FORMAT_STYLE" + "DOTNET_SLN_FORMAT_WHITESPACE" + "POWERSHELL" + "RUST_2015" + "RUST_2018" + "RUST_2021" + "RUST_CLIPPY" + ) # Remove from LANGUAGE_ARRAY debug "Removing Languages from LANGUAGE_ARRAY for slim image..." diff --git a/scripts/linterVersions.sh b/scripts/linterVersions.sh index 5c86a929..91cf11f7 100755 --- a/scripts/linterVersions.sh +++ b/scripts/linterVersions.sh @@ -82,6 +82,9 @@ LINTER_NAMES_ARRAY['YAML']="yamllint" if [[ "${IMAGE}" == "standard" ]]; then LINTER_NAMES_ARRAY['ARM']="arm-ttk" LINTER_NAMES_ARRAY['CSHARP']="dotnet" + LINTER_NAMES_ARRAY['DOTNET_SLN_FORMAT_ANALYZERS']="dotnet" + LINTER_NAMES_ARRAY['DOTNET_SLN_FORMAT_STYLE']="dotnet" + LINTER_NAMES_ARRAY['DOTNET_SLN_FORMAT_WHITESPACE']="dotnet" LINTER_NAMES_ARRAY['POWERSHELL']="pwsh" LINTER_NAMES_ARRAY['RUST_2015']="rustfmt" LINTER_NAMES_ARRAY['RUST_2018']="rustfmt" diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md index e846c7b0..d2372770 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-failure-standard.md @@ -18,6 +18,9 @@ | CSS_PRETTIER | Fail ❌ | | DART | Fail ❌ | | DOCKERFILE_HADOLINT | Fail ❌ | +| DOTNET_SLN_FORMAT_ANALYZERS | Fail ❌ | +| DOTNET_SLN_FORMAT_STYLE | Fail ❌ | +| DOTNET_SLN_FORMAT_WHITESPACE | Fail ❌ | | EDITORCONFIG | Fail ❌ | | ENV | Fail ❌ | | GITHUB_ACTIONS | Fail ❌ | diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md index d1f269c9..714390e2 100644 --- a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-expect-success-standard.md @@ -18,6 +18,9 @@ | CSS_PRETTIER | Pass ✅ | | DART | Pass ✅ | | DOCKERFILE_HADOLINT | Pass ✅ | +| DOTNET_SLN_FORMAT_ANALYZERS | Pass ✅ | +| DOTNET_SLN_FORMAT_STYLE | Pass ✅ | +| DOTNET_SLN_FORMAT_WHITESPACE | Pass ✅ | | EDITORCONFIG | Pass ✅ | | ENV | Pass ✅ | | GITHUB_ACTIONS | Pass ✅ | diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md new file mode 100644 index 00000000..5e82a5b8 --- /dev/null +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-slim.md @@ -0,0 +1,46 @@ +# Super-linter summary + + +| Language | Validation result | +| -----------------------|-------------------| +| ANSIBLE | Pass ✅ | +| CLANG_FORMAT | Pass ✅ | +| CSS | Pass ✅ | +| CSS_PRETTIER | Pass ✅ | +| ENV | Pass ✅ | +| GO | Pass ✅ | +| GO_MODULES | Pass ✅ | +| GOOGLE_JAVA_FORMAT | Pass ✅ | +| GRAPHQL_PRETTIER | Pass ✅ | +| GROOVY | Fail ❌ | +| HTML_PRETTIER | Pass ✅ | +| JAVASCRIPT_ES | Pass ✅ | +| JAVASCRIPT_PRETTIER | Pass ✅ | +| JAVASCRIPT_STANDARD | Pass ✅ | +| JSON | Fail ❌ | +| JSON_PRETTIER | Pass ✅ | +| JSONC | Pass ✅ | +| JSX | Fail ❌ | +| JSX_PRETTIER | Pass ✅ | +| MARKDOWN | Pass ✅ | +| MARKDOWN_PRETTIER | Pass ✅ | +| NATURAL_LANGUAGE | Pass ✅ | +| PROTOBUF | Fail ❌ | +| PYTHON_BLACK | Pass ✅ | +| PYTHON_ISORT | Pass ✅ | +| PYTHON_RUFF | Pass ✅ | +| RUBY | Fail ❌ | +| SCALAFMT | Pass ✅ | +| SHELL_SHFMT | Pass ✅ | +| SNAKEMAKE_SNAKEFMT | Pass ✅ | +| SQLFLUFF | Pass ✅ | +| TERRAFORM_FMT | Pass ✅ | +| TSX | Fail ❌ | +| TYPESCRIPT_ES | Pass ✅ | +| TYPESCRIPT_PRETTIER | Pass ✅ | +| TYPESCRIPT_STANDARD | Pass ✅ | +| VUE_PRETTIER | Pass ✅ | +| YAML_PRETTIER | Pass ✅ | + + +Super-linter detected linting errors diff --git a/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-standard.md b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-standard.md new file mode 100644 index 00000000..ba5ff15d --- /dev/null +++ b/test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-standard.md @@ -0,0 +1,55 @@ +# Super-linter summary + + +| Language | Validation result | +| -----------------------|-------------------| +| ANSIBLE | Pass ✅ | +| CLANG_FORMAT | Pass ✅ | +| CSHARP | Pass ✅ | +| CSS | Pass ✅ | +| CSS_PRETTIER | Pass ✅ | +| DOTNET_SLN_FORMAT_ANALYZERS | Pass ✅ | +| DOTNET_SLN_FORMAT_STYLE | Pass ✅ | +| DOTNET_SLN_FORMAT_WHITESPACE | Pass ✅ | +| ENV | Pass ✅ | +| GO | Pass ✅ | +| GO_MODULES | Pass ✅ | +| GOOGLE_JAVA_FORMAT | Pass ✅ | +| GRAPHQL_PRETTIER | Pass ✅ | +| GROOVY | Fail ❌ | +| HTML_PRETTIER | Pass ✅ | +| JAVASCRIPT_ES | Pass ✅ | +| JAVASCRIPT_PRETTIER | Pass ✅ | +| JAVASCRIPT_STANDARD | Pass ✅ | +| JSON | Fail ❌ | +| JSON_PRETTIER | Pass ✅ | +| JSONC | Pass ✅ | +| JSX | Fail ❌ | +| JSX_PRETTIER | Pass ✅ | +| MARKDOWN | Pass ✅ | +| MARKDOWN_PRETTIER | Pass ✅ | +| NATURAL_LANGUAGE | Pass ✅ | +| POWERSHELL | Fail ❌ | +| PROTOBUF | Fail ❌ | +| PYTHON_BLACK | Pass ✅ | +| PYTHON_ISORT | Pass ✅ | +| PYTHON_RUFF | Pass ✅ | +| RUBY | Fail ❌ | +| RUST_2015 | Pass ✅ | +| RUST_2018 | Pass ✅ | +| RUST_2021 | Pass ✅ | +| RUST_CLIPPY | Pass ✅ | +| SCALAFMT | Pass ✅ | +| SHELL_SHFMT | Pass ✅ | +| SNAKEMAKE_SNAKEFMT | Pass ✅ | +| SQLFLUFF | Pass ✅ | +| TERRAFORM_FMT | Pass ✅ | +| TSX | Fail ❌ | +| TYPESCRIPT_ES | Pass ✅ | +| TYPESCRIPT_PRETTIER | Pass ✅ | +| TYPESCRIPT_STANDARD | Pass ✅ | +| VUE_PRETTIER | Pass ✅ | +| YAML_PRETTIER | Pass ✅ | + + +Super-linter detected linting errors diff --git a/test/linters/dotnet_sln_format_analyzers/bad/.editorconfig b/test/linters/dotnet_sln_format_analyzers/bad/.editorconfig new file mode 100644 index 00000000..3f8b8fc9 --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/bad/.editorconfig @@ -0,0 +1,5 @@ +root = false + +[*.{cs}] + +dotnet_diagnostic.SA1200.severity = error diff --git a/test/linters/dotnet_sln_format_analyzers/bad/Directory.Build.props b/test/linters/dotnet_sln_format_analyzers/bad/Directory.Build.props new file mode 100644 index 00000000..a0ed3022 --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/bad/Directory.Build.props @@ -0,0 +1,11 @@ + + + 2024 + MIT + https://github.com/dotnet/format + 11 + + true + + + diff --git a/test/linters/dotnet_sln_format_analyzers/bad/format.sln b/test/linters/dotnet_sln_format_analyzers/bad/format.sln new file mode 100644 index 00000000..b552fec8 --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/bad/format.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-format", "src\dotnet-format.csproj", "{7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/test/linters/dotnet_sln_format_analyzers/bad/src/Program.cs b/test/linters/dotnet_sln_format_analyzers/bad/src/Program.cs new file mode 100644 index 00000000..aadf6341 --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/bad/src/Program.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Tools.Commands; + +namespace Microsoft.CodeAnalysis.Tools +{ + internal class Program + { + private static async Task Main(string[] args) + { + var rootCommand = RootFormatCommand.GetCommand(); + int v = (int)0; + return await rootCommand.Parse(args).InvokeAsync(CancellationToken.None); + } + } +} diff --git a/test/linters/dotnet_sln_format_analyzers/bad/src/dotnet-format.csproj b/test/linters/dotnet_sln_format_analyzers/bad/src/dotnet-format.csproj new file mode 100644 index 00000000..e2899b6e --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/bad/src/dotnet-format.csproj @@ -0,0 +1,40 @@ + + + + net8.0 + Exe + Microsoft.CodeAnalysis.Tools + true + Enable + $(NoWarn);8002 + Command line tool for formatting C# and Visual Basic code files based on .editorconfig settings. + LatestMajor + + true + true + Icon.png + $(MSBuildThisFileDirectory)Resources\icon.png + + + true + + + win-x64;win-x86;osx-x64 + + + + + + + + + + + + + + + diff --git a/test/linters/dotnet_sln_format_analyzers/good/.editorconfig b/test/linters/dotnet_sln_format_analyzers/good/.editorconfig new file mode 100644 index 00000000..5f89b86f --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/good/.editorconfig @@ -0,0 +1,6 @@ +root = false + +[*.{cs}] + +dotnet_diagnostic.SA1200.severity = error +dotnet_diagnostic.SA1600.severity = none diff --git a/test/linters/dotnet_sln_format_analyzers/good/Directory.Build.props b/test/linters/dotnet_sln_format_analyzers/good/Directory.Build.props new file mode 100644 index 00000000..a0ed3022 --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/good/Directory.Build.props @@ -0,0 +1,11 @@ + + + 2024 + MIT + https://github.com/dotnet/format + 11 + + true + + + diff --git a/test/linters/dotnet_sln_format_analyzers/good/format.sln b/test/linters/dotnet_sln_format_analyzers/good/format.sln new file mode 100644 index 00000000..b552fec8 --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/good/format.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-format", "src\dotnet-format.csproj", "{7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/test/linters/dotnet_sln_format_analyzers/good/src/Program.cs b/test/linters/dotnet_sln_format_analyzers/good/src/Program.cs new file mode 100644 index 00000000..ae990b74 --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/good/src/Program.cs @@ -0,0 +1,20 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace Microsoft.CodeAnalysis.Tools +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Tools.Commands; + + internal class Program + { + private static async Task Main(string[] args) + { + var rootCommand = RootFormatCommand.GetCommand(); + int v = (int)0; + return await rootCommand.Parse(args).InvokeAsync(CancellationToken.None); + } + } +} diff --git a/test/linters/dotnet_sln_format_analyzers/good/src/dotnet-format.csproj b/test/linters/dotnet_sln_format_analyzers/good/src/dotnet-format.csproj new file mode 100644 index 00000000..e2899b6e --- /dev/null +++ b/test/linters/dotnet_sln_format_analyzers/good/src/dotnet-format.csproj @@ -0,0 +1,40 @@ + + + + net8.0 + Exe + Microsoft.CodeAnalysis.Tools + true + Enable + $(NoWarn);8002 + Command line tool for formatting C# and Visual Basic code files based on .editorconfig settings. + LatestMajor + + true + true + Icon.png + $(MSBuildThisFileDirectory)Resources\icon.png + + + true + + + win-x64;win-x86;osx-x64 + + + + + + + + + + + + + + + diff --git a/test/linters/dotnet_sln_format_style/bad/.editorconfig b/test/linters/dotnet_sln_format_style/bad/.editorconfig new file mode 100644 index 00000000..9d3a5464 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/bad/.editorconfig @@ -0,0 +1,5 @@ +root = false + +[*.{cs}] + +dotnet_analyzer_diagnostic.category-Style.severity = error diff --git a/test/linters/dotnet_sln_format_style/bad/Directory.Build.props b/test/linters/dotnet_sln_format_style/bad/Directory.Build.props new file mode 100644 index 00000000..a0ed3022 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/bad/Directory.Build.props @@ -0,0 +1,11 @@ + + + 2024 + MIT + https://github.com/dotnet/format + 11 + + true + + + diff --git a/test/linters/dotnet_sln_format_style/bad/format.sln b/test/linters/dotnet_sln_format_style/bad/format.sln new file mode 100644 index 00000000..b552fec8 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/bad/format.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-format", "src\dotnet-format.csproj", "{7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/test/linters/dotnet_sln_format_style/bad/src/Program.cs b/test/linters/dotnet_sln_format_style/bad/src/Program.cs new file mode 100644 index 00000000..7c83e288 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/bad/src/Program.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Tools.Commands; + +namespace Microsoft.CodeAnalysis.Tools +{ + internal class Program + { + private static async Task Main(string[] args) + { + var rootCommand = RootFormatCommand.GetCommand(); + return await rootCommand.Parse(args).InvokeAsync(CancellationToken.None); + } + } +} diff --git a/test/linters/dotnet_sln_format_style/bad/src/dotnet-format.csproj b/test/linters/dotnet_sln_format_style/bad/src/dotnet-format.csproj new file mode 100644 index 00000000..c91ac9e5 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/bad/src/dotnet-format.csproj @@ -0,0 +1,36 @@ + + + + net8.0 + Exe + Microsoft.CodeAnalysis.Tools + true + Enable + $(NoWarn);8002 + Command line tool for formatting C# and Visual Basic code files based on .editorconfig settings. + LatestMajor + + true + true + Icon.png + $(MSBuildThisFileDirectory)Resources\icon.png + + + true + + + win-x64;win-x86;osx-x64 + + + + + + + + + + + diff --git a/test/linters/dotnet_sln_format_style/good/.editorconfig b/test/linters/dotnet_sln_format_style/good/.editorconfig new file mode 100644 index 00000000..9d3a5464 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/good/.editorconfig @@ -0,0 +1,5 @@ +root = false + +[*.{cs}] + +dotnet_analyzer_diagnostic.category-Style.severity = error diff --git a/test/linters/dotnet_sln_format_style/good/Directory.Build.props b/test/linters/dotnet_sln_format_style/good/Directory.Build.props new file mode 100644 index 00000000..a0ed3022 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/good/Directory.Build.props @@ -0,0 +1,11 @@ + + + 2024 + MIT + https://github.com/dotnet/format + 11 + + true + + + diff --git a/test/linters/dotnet_sln_format_style/good/format.sln b/test/linters/dotnet_sln_format_style/good/format.sln new file mode 100644 index 00000000..b552fec8 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/good/format.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-format", "src\dotnet-format.csproj", "{7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/test/linters/dotnet_sln_format_style/good/src/Program.cs b/test/linters/dotnet_sln_format_style/good/src/Program.cs new file mode 100644 index 00000000..540aed79 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/good/src/Program.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Threading; + +var rootCommand = RootFormatCommand.GetCommand(); +return await rootCommand.Parse(args).InvokeAsync(CancellationToken.None); diff --git a/test/linters/dotnet_sln_format_style/good/src/dotnet-format.csproj b/test/linters/dotnet_sln_format_style/good/src/dotnet-format.csproj new file mode 100644 index 00000000..c91ac9e5 --- /dev/null +++ b/test/linters/dotnet_sln_format_style/good/src/dotnet-format.csproj @@ -0,0 +1,36 @@ + + + + net8.0 + Exe + Microsoft.CodeAnalysis.Tools + true + Enable + $(NoWarn);8002 + Command line tool for formatting C# and Visual Basic code files based on .editorconfig settings. + LatestMajor + + true + true + Icon.png + $(MSBuildThisFileDirectory)Resources\icon.png + + + true + + + win-x64;win-x86;osx-x64 + + + + + + + + + + + diff --git a/test/linters/dotnet_sln_format_whitespace/bad/format.sln b/test/linters/dotnet_sln_format_whitespace/bad/format.sln new file mode 100644 index 00000000..b552fec8 --- /dev/null +++ b/test/linters/dotnet_sln_format_whitespace/bad/format.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-format", "src\dotnet-format.csproj", "{7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/test/linters/dotnet_sln_format_whitespace/bad/src/Program.cs b/test/linters/dotnet_sln_format_whitespace/bad/src/Program.cs new file mode 100644 index 00000000..7c83e288 --- /dev/null +++ b/test/linters/dotnet_sln_format_whitespace/bad/src/Program.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Tools.Commands; + +namespace Microsoft.CodeAnalysis.Tools +{ + internal class Program + { + private static async Task Main(string[] args) + { + var rootCommand = RootFormatCommand.GetCommand(); + return await rootCommand.Parse(args).InvokeAsync(CancellationToken.None); + } + } +} diff --git a/test/linters/dotnet_sln_format_whitespace/bad/src/dotnet-format.csproj b/test/linters/dotnet_sln_format_whitespace/bad/src/dotnet-format.csproj new file mode 100644 index 00000000..4566c435 --- /dev/null +++ b/test/linters/dotnet_sln_format_whitespace/bad/src/dotnet-format.csproj @@ -0,0 +1,63 @@ + + + + $(NetCurrent) + Exe + Microsoft.CodeAnalysis.Tools + true + Enable + $(NoWarn);8002 + Command line tool for formatting C# and Visual Basic code files based on .editorconfig settings. + LatestMajor + + true + true + Icon.png + $(MSBuildThisFileDirectory)Resources\icon.png + + + true + + + win-x64;win-x86;osx-x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/linters/dotnet_sln_format_whitespace/good/format.sln b/test/linters/dotnet_sln_format_whitespace/good/format.sln new file mode 100644 index 00000000..b552fec8 --- /dev/null +++ b/test/linters/dotnet_sln_format_whitespace/good/format.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-format", "src\dotnet-format.csproj", "{7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x64.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.ActiveCfg = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Debug|x86.Build.0 = Debug|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|Any CPU.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x64.Build.0 = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.ActiveCfg = Release|Any CPU + {7DFBB9BC-E3A9-46EB-B225-9DFD4E57D344}.Release|x86.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x64.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Debug|x86.Build.0 = Debug|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|Any CPU.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x64.Build.0 = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.ActiveCfg = Release|Any CPU + {4F181F8B-534F-48A6-A28B-0D11F5AEFF55}.Release|x86.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x64.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.ActiveCfg = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Debug|x86.Build.0 = Debug|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|Any CPU.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x64.Build.0 = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.ActiveCfg = Release|Any CPU + {9E6BD2C1-9E04-428A-B960-BE1B786CA910}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/test/linters/dotnet_sln_format_whitespace/good/src/Program.cs b/test/linters/dotnet_sln_format_whitespace/good/src/Program.cs new file mode 100644 index 00000000..7cbad1eb --- /dev/null +++ b/test/linters/dotnet_sln_format_whitespace/good/src/Program.cs @@ -0,0 +1,15 @@ +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Tools.Commands; + +namespace Microsoft.CodeAnalysis.Tools +{ + internal class Program + { + private static async Task Main(string[] args) + { + var rootCommand = RootFormatCommand.GetCommand(); + return await rootCommand.Parse(args).InvokeAsync(CancellationToken.None); + } + } +} diff --git a/test/linters/dotnet_sln_format_whitespace/good/src/dotnet-format.csproj b/test/linters/dotnet_sln_format_whitespace/good/src/dotnet-format.csproj new file mode 100644 index 00000000..4566c435 --- /dev/null +++ b/test/linters/dotnet_sln_format_whitespace/good/src/dotnet-format.csproj @@ -0,0 +1,63 @@ + + + + $(NetCurrent) + Exe + Microsoft.CodeAnalysis.Tools + true + Enable + $(NoWarn);8002 + Command line tool for formatting C# and Visual Basic code files based on .editorconfig settings. + LatestMajor + + true + true + Icon.png + $(MSBuildThisFileDirectory)Resources\icon.png + + + true + + + win-x64;win-x86;osx-x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/run-super-linter-tests.sh b/test/run-super-linter-tests.sh index 54227874..ea79a8e6 100755 --- a/test/run-super-linter-tests.sh +++ b/test/run-super-linter-tests.sh @@ -14,7 +14,7 @@ debug "Super-linter container image type: ${SUPER_LINTER_CONTAINER_IMAGE_TYPE}" DEFAULT_BRANCH="main" -COMMAND_TO_RUN=(docker run -t -e DEFAULT_BRANCH="${DEFAULT_BRANCH}" -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE=true) +COMMAND_TO_RUN=(docker run --rm -t -e DEFAULT_BRANCH="${DEFAULT_BRANCH}" -e ENABLE_GITHUB_ACTIONS_GROUP_TITLE="true") ignore_test_cases() { COMMAND_TO_RUN+=(-e FILTER_REGEX_EXCLUDE=".*(/test/linters/|CHANGELOG.md).*") @@ -25,7 +25,7 @@ configure_typescript_for_test_cases() { } configure_linters_for_test_cases() { - COMMAND_TO_RUN+=(-e TEST_CASE_RUN=true -e JSCPD_CONFIG_FILE=".jscpd-test-linters.json" -e RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES="default.json,hoge.json") + COMMAND_TO_RUN+=(-e TEST_CASE_RUN="true" -e JSCPD_CONFIG_FILE=".jscpd-test-linters.json" -e RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES="default.json,hoge.json") configure_typescript_for_test_cases } @@ -44,7 +44,6 @@ run_test_cases_expect_success() { run_test_cases_log_level() { run_test_cases_expect_success - CREATE_LOG_FILE="true" LOG_LEVEL="NOTICE" } @@ -68,6 +67,16 @@ run_test_case_bash_exec_library_expect_success() { COMMAND_TO_RUN+=(-e BASH_EXEC_IGNORE_LIBRARIES="true") } +run_test_case_dont_save_super_linter_log_file() { + run_test_cases_expect_success + CREATE_LOG_FILE="false" +} + +run_test_case_dont_save_super_linter_output() { + run_test_cases_expect_success + SAVE_SUPER_LINTER_OUTPUT="false" +} + initialize_git_repository_and_test_args() { local GIT_REPOSITORY_PATH="${1}" # shellcheck disable=SC2064 # Once the path is set, we don't expect it to change @@ -107,7 +116,7 @@ run_test_case_git_initial_commit() { initialize_git_repository_and_test_args "${GIT_REPOSITORY_PATH}" "test/data/github-event/github-event-push.json" initialize_github_sha "${GIT_REPOSITORY_PATH}" - COMMAND_TO_RUN+=(-e VALIDATE_JSON=true) + COMMAND_TO_RUN+=(-e VALIDATE_JSON="true") } run_test_case_merge_commit_push() { @@ -138,18 +147,17 @@ run_test_case_merge_commit_push() { git -C "${GIT_REPOSITORY_PATH}" log --all --graph --abbrev-commit --decorate --format=oneline initialize_github_sha "${GIT_REPOSITORY_PATH}" - COMMAND_TO_RUN+=(-e VALIDATE_JSON=true) + COMMAND_TO_RUN+=(-e VALIDATE_JSON="true") } run_test_case_use_find_and_ignore_gitignored_files() { ignore_test_cases - COMMAND_TO_RUN+=(-e IGNORE_GITIGNORED_FILES=true) - COMMAND_TO_RUN+=(-e USE_FIND_ALGORITHM=true) + COMMAND_TO_RUN+=(-e IGNORE_GITIGNORED_FILES="true") + COMMAND_TO_RUN+=(-e USE_FIND_ALGORITHM="true") } run_test_cases_save_super_linter_output() { run_test_cases_expect_success - SAVE_SUPER_LINTER_OUTPUT="true" } run_test_cases_save_super_linter_output_custom_path() { @@ -164,14 +172,10 @@ run_test_case_custom_summary() { run_test_case_gitleaks_custom_log_level() { run_test_cases_expect_success - CREATE_LOG_FILE="true" - SAVE_SUPER_LINTER_OUTPUT="true" COMMAND_TO_RUN+=(--env GITLEAKS_LOG_LEVEL="warn") } run_test_case_fix_mode() { - CREATE_LOG_FILE="true" - SAVE_SUPER_LINTER_OUTPUT="true" VERIFY_FIX_MODE="true" GIT_REPOSITORY_PATH="$(mktemp -d)" @@ -212,20 +216,23 @@ run_test_case_fix_mode() { # Enable test mode so we run linters and formatters only against their test # cases - COMMAND_TO_RUN+=(--env FIX_MODE_TEST_CASE_RUN=true) - COMMAND_TO_RUN+=(--env TEST_CASE_RUN=true) + COMMAND_TO_RUN+=(--env FIX_MODE_TEST_CASE_RUN="true") + COMMAND_TO_RUN+=(--env TEST_CASE_RUN="true") COMMAND_TO_RUN+=(--env ANSIBLE_DIRECTORY="/test/linters/ansible/bad") configure_typescript_for_test_cases # Some linters report a non-zero exit code even if they fix all the issues EXPECTED_EXIT_CODE=2 + + EXPECTED_SUPER_LINTER_SUMMARY_FILE_PATH="test/data/super-linter-summary/markdown/table/expected-summary-test-linters-fix-mode-${SUPER_LINTER_CONTAINER_IMAGE_TYPE}.md" } # Run the test setup function ${TEST_FUNCTION_NAME} -CREATE_LOG_FILE="${CREATE_LOG_FILE:-false}" -SAVE_SUPER_LINTER_OUTPUT="${SAVE_SUPER_LINTER_OUTPUT:-false}" +CREATE_LOG_FILE="${CREATE_LOG_FILE:-"true"}" +debug "CREATE_LOG_FILE: ${CREATE_LOG_FILE}" +SAVE_SUPER_LINTER_OUTPUT="${SAVE_SUPER_LINTER_OUTPUT:-true}" SUPER_LINTER_WORKSPACE="${SUPER_LINTER_WORKSPACE:-$(pwd)}" COMMAND_TO_RUN+=(-v "${SUPER_LINTER_WORKSPACE}":"/tmp/lint") @@ -421,7 +428,10 @@ if [[ "${VERIFY_FIX_MODE:-}" == "true" ]]; then fi if find "${BAD_TEST_CASE_DESTINATION_PATH}" \( -type f ! -readable -or -type d \( ! -readable -or ! -executable -or ! -writable \) \) -print | grep -q .; then - if [[ "${LANGUAGE}" == "RUST_CLIPPY" ]] || + if [[ "${LANGUAGE}" == "DOTNET_SLN_FORMAT_ANALYZERS" ]] || + [[ "${LANGUAGE}" == "DOTNET_SLN_FORMAT_STYLE" ]] || + [[ "${LANGUAGE}" == "DOTNET_SLN_FORMAT_WHITESPACE" ]] || + [[ "${LANGUAGE}" == "RUST_CLIPPY" ]] || [[ "${LANGUAGE}" == "SHELL_SHFMT" ]] || [[ "${LANGUAGE}" == "SQLFLUFF" ]]; then debug "${LANGUAGE} is a known case of a tool that doesn't preserve the ownership of files or directories in fix mode. Need to recursively change ownership of ${BAD_TEST_CASE_DESTINATION_PATH}" diff --git a/test/testUtils.sh b/test/testUtils.sh index 8257dcd8..fe5634b6 100755 --- a/test/testUtils.sh +++ b/test/testUtils.sh @@ -8,6 +8,10 @@ set -o pipefail # shellcheck disable=SC2034 LOG_LEVEL="DEBUG" +# Create log file by default +# shellcheck disable=SC2034 +CREATE_LOG_FILE="true" + # shellcheck source=/dev/null source "lib/functions/log.sh" @@ -23,6 +27,9 @@ LANGUAGES_WITH_FIX_MODE=( "CSHARP" "CSS" "CSS_PRETTIER" + "DOTNET_SLN_FORMAT_ANALYZERS" + "DOTNET_SLN_FORMAT_STYLE" + "DOTNET_SLN_FORMAT_WHITESPACE" "ENV" "GO_MODULES" "GO" @@ -70,6 +77,9 @@ LANGUAGES_WITH_FIX_MODE=( LANGUAGES_NOT_IN_SLIM_IMAGE=( "ARM" "CSHARP" + "DOTNET_SLN_FORMAT_ANALYZERS" + "DOTNET_SLN_FORMAT_STYLE" + "DOTNET_SLN_FORMAT_WHITESPACE" "POWERSHELL" "RUST_2015" "RUST_2018"