From 65a42bda32fb90cb5ad98309fb585f8fb7a8ac1a Mon Sep 17 00:00:00 2001 From: Konstantin Tyukalov <52399739+KonstantinTyukalov@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:55:17 +0400 Subject: [PATCH] Add lint & lint-verify commands (#5038) * add cmd_lint{_verify} * Ignore IDE0010 * Force to use lang 10.0 (net 6) --- .editorconfig | 2 +- src/Common.props | 1 + src/dev.sh | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 85323ba60a..e0c9ec240f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -59,7 +59,7 @@ dotnet_diagnostic.IDE0007.severity = none dotnet_diagnostic.IDE0008.severity = none # IDE0010: Add missing cases -dotnet_diagnostic.IDE0010.severity = warning +dotnet_diagnostic.IDE0010.severity = none # IDE0011: Add braces dotnet_diagnostic.IDE0011.severity = suggestion diff --git a/src/Common.props b/src/Common.props index 6251bbb91d..8b1b645a91 100644 --- a/src/Common.props +++ b/src/Common.props @@ -1,5 +1,6 @@ + 10.0 net6.0;net8.0 $(PackageRuntime) true diff --git a/src/dev.sh b/src/dev.sh index e8c08ebadc..d292ac5106 100755 --- a/src/dev.sh +++ b/src/dev.sh @@ -348,6 +348,18 @@ function cmd_report() { fi } +function cmd_lint() { + heading "Linting source code" + + "${DOTNET_DIR}/dotnet" format -v diag "$REPO_ROOT/azure-pipelines-agent.sln" || checkRC "cmd_lint" +} + +function cmd_lint_verify() { + heading "Validating linted code" + + "${DOTNET_DIR}/dotnet" format --verify-no-changes -v diag "$REPO_ROOT/azure-pipelines-agent.sln" || checkRC "cmd_lint_verify" +} + detect_platform_and_runtime_id echo "Current platform: $CURRENT_PLATFORM" echo "Current runtime ID: $DETECTED_RUNTIME_ID" @@ -414,6 +426,8 @@ case $DEV_CMD in "p") cmd_package ;; "hash") cmd_hash ;; "report") cmd_report ;; +"lint") cmd_lint ;; +"lint-verify") cmd_lint_verify ;; *) echo "Invalid command. Use (l)ayout, (b)uild, (t)est, test(l0), test(l1), or (p)ackage." ;; esac