From b2bbcde4aa414cfa341442210c9136378d3300a3 Mon Sep 17 00:00:00 2001 From: Spencer Schrock Date: Mon, 3 Mar 2025 08:47:30 -0700 Subject: [PATCH 1/2] explicitly specify enabled gocritic checks Disable all the checks, then turn the ones we want on one-by-one. This list matches what we already had in the config, plus the checks which are enabled by default. The end result is the same list of linters, but we silence the warnings reported in #4439. Signed-off-by: Spencer Schrock --- .golangci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 14318661612..32ed605afb4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -110,20 +110,29 @@ linters-settings: - default - prefix(github.com/ossf/scorecard) gocritic: + disable-all: true enabled-checks: # Diagnostic - appendAssign + - argOrder + - badCall - badCond - caseOrder - codegenComment - commentedOutCode - deprecatedComment + - dupArg - dupBranchBody - dupCase - dupSubExpr - exitAfterDefer + - flagDeref - flagName + - mapKey - nilValReturn + - offBy1 + - sloppyLen + - sloppyTypeAssert - weakCond - octalLiteral @@ -134,6 +143,7 @@ linters-settings: - rangeValCopy # Style + - assignOp - boolExprSimplify - captLocal - commentFormatting @@ -145,12 +155,18 @@ linters-settings: - hexLiteral - ifElseChain - methodExprCall + - newDeref + - regexpMust - singleCaseSwitch + - switchTrue - typeAssertChain - typeSwitchVar - underef - unlabelStmt - unlambda + - unslice + - valSwap + - wrapperFunc # Opinionated - builtinShadow From b9a60755f939b3d6bc241d70908046d1ca13be23 Mon Sep 17 00:00:00 2001 From: Spencer Schrock Date: Mon, 3 Mar 2025 08:49:42 -0700 Subject: [PATCH 2/2] sort gocritic linters alphabetically by section Signed-off-by: Spencer Schrock --- .golangci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 32ed605afb4..2069fe86ee7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -130,11 +130,11 @@ linters-settings: - flagName - mapKey - nilValReturn + - octalLiteral - offBy1 - sloppyLen - sloppyTypeAssert - weakCond - - octalLiteral # Performance - appendCombine @@ -146,8 +146,8 @@ linters-settings: - assignOp - boolExprSimplify - captLocal - - commentFormatting - commentedOutImport + - commentFormatting - defaultCaseOrder - docStub - elseif