From a5792b4f847be643aa457946005e84fd9d19701a Mon Sep 17 00:00:00 2001 From: John Saigle Date: Wed, 17 Sep 2025 17:25:38 -0400 Subject: [PATCH 1/3] ci(gocritic): use deny-list for disabled rules so that newly added rules will get run - Ensures that all rules are enabled by default with a deny-list, instead of disabling all rules and using an allow-list. This change allows us to benefit from new rules that could be added to gocritic in the future. Our current policy in CI is to fail on new rules and this is already in place for e.g. clippy lints for new Rust releases. --- .golangci.yml | 43 +++++++++++-------------------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c6a58c2313..4865b9190e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -127,38 +127,17 @@ linters: exclude-godoc-examples: true analyze-types: true gocritic: - disable-all: true - # disabled-checks: - # - exitAfterDefer - # - assignOp - # - ifElseChain - # - elseif - enabled-checks: - - argOrder - - badCall - - badCond - - badLock - - badRegexp - - badSorting - - builtinShadow - - builtinShadowDecl - - caseOrder - - dupArg - - dupBranchBody - - dupCase - - dupSubExpr - - externalErrorReassign - - importShadow - - mapKey - - newDeref - - offBy1 - - regexpPattern - - sloppyReassign - - truncateCmp - - uncheckedInlineErr - - weakCond - # performance lints - - indexAlloc + disabled-checks: + - assignOp + - appendAssign + - captLocal # We should probably enable this one + - commentFormatting # We should probably enable this one + - elseif + - exitAfterDefer + - ifElseChain + - sloppyLen + - underef + - unslice nolintlint: # Disable to ensure that all nolint directives actually have an effect. # Default: false From 03f63c16712742a55dc9c5eabfc07bebbea59264 Mon Sep 17 00:00:00 2001 From: John Saigle Date: Wed, 17 Sep 2025 17:27:39 -0400 Subject: [PATCH 2/3] fix singleCaseSwitch lint violation --- node/pkg/common/chain_id_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/pkg/common/chain_id_test.go b/node/pkg/common/chain_id_test.go index edf0d8816f..d7d085b090 100644 --- a/node/pkg/common/chain_id_test.go +++ b/node/pkg/common/chain_id_test.go @@ -102,8 +102,8 @@ func parseProtoFile() ([]ProtoEntry, error) { // This traverses the parsed Go code looking for constant declarations // that have the type "ChainID" ast.Inspect(node, func(n ast.Node) bool { - switch x := n.(type) { - case *ast.GenDecl: + x, ok := n.(*ast.GenDecl) + if ok { if x.Tok == token.CONST { for _, spec := range x.Specs { if vspec, ok := spec.(*ast.ValueSpec); ok { From bbf11f14da383b17fde21e7694412207a30f0848 Mon Sep 17 00:00:00 2001 From: John Saigle Date: Thu, 18 Sep 2025 08:31:53 -0400 Subject: [PATCH 3/3] formatting --- node/pkg/common/chain_id_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/pkg/common/chain_id_test.go b/node/pkg/common/chain_id_test.go index d7d085b090..a57a918de1 100644 --- a/node/pkg/common/chain_id_test.go +++ b/node/pkg/common/chain_id_test.go @@ -102,7 +102,7 @@ func parseProtoFile() ([]ProtoEntry, error) { // This traverses the parsed Go code looking for constant declarations // that have the type "ChainID" ast.Inspect(node, func(n ast.Node) bool { - x, ok := n.(*ast.GenDecl) + x, ok := n.(*ast.GenDecl) if ok { if x.Tok == token.CONST { for _, spec := range x.Specs {