From 98e3f2b80fadfee5701a36c450e527ebbc7f3b5f Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Tue, 9 Jan 2024 17:29:36 -0600 Subject: [PATCH] sort static analyzers, add more, fix violations (#13441) --- BUILD.bazel | 74 ++++++++++++------- .../prysm/v1alpha1/validator/proposer_test.go | 4 - beacon-chain/sync/blobs_test.go | 2 +- .../sync/initial-sync/blocks_fetcher_test.go | 2 - .../sync/rpc_beacon_blocks_by_range_test.go | 1 - nogo_config.json | 18 +++++ 6 files changed, 66 insertions(+), 35 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 9bcaf6fed..030bffe39 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -194,33 +194,6 @@ nogo( config = ":nogo_config_with_excludes", visibility = ["//visibility:public"], deps = [ - "@org_golang_x_tools//go/analysis/passes/unsafeptr:go_default_library", - "@org_golang_x_tools//go/analysis/passes/unreachable:go_default_library", - "@org_golang_x_tools//go/analysis/passes/unmarshal:go_default_library", - "@org_golang_x_tools//go/analysis/passes/tests:go_default_library", - "@org_golang_x_tools//go/analysis/passes/structtag:go_default_library", - "@org_golang_x_tools//go/analysis/passes/stdmethods:go_default_library", - "@org_golang_x_tools//go/analysis/passes/shift:go_default_library", - # "@org_golang_x_tools//go/analysis/passes/shadow:go_default_library", - "@org_golang_x_tools//go/analysis/passes/printf:go_default_library", - "@org_golang_x_tools//go/analysis/passes/pkgfact:go_default_library", - "@org_golang_x_tools//go/analysis/passes/nilness:go_default_library", - "@org_golang_x_tools//go/analysis/passes/nilfunc:go_default_library", - "@org_golang_x_tools//go/analysis/passes/loopclosure:go_default_library", - "@org_golang_x_tools//go/analysis/passes/httpresponse:go_default_library", - "@org_golang_x_tools//go/analysis/passes/findcall:go_default_library", - "@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_default_library", - "@org_golang_x_tools//go/analysis/passes/ctrlflow:go_default_library", - "@org_golang_x_tools//go/analysis/passes/copylock:go_default_library", - # "@org_golang_x_tools//go/analysis/passes/cgocall:go_default_library", - "@org_golang_x_tools//go/analysis/passes/buildtag:go_default_library", - "@org_golang_x_tools//go/analysis/passes/buildssa:go_default_library", - "@org_golang_x_tools//go/analysis/passes/bools:go_default_library", - "@org_golang_x_tools//go/analysis/passes/atomicalign:go_default_library", - "@org_golang_x_tools//go/analysis/passes/atomic:go_default_library", - "@org_golang_x_tools//go/analysis/passes/assign:go_default_library", - "@org_golang_x_tools//go/analysis/passes/inspect:go_default_library", - "@org_golang_x_tools//go/analysis/passes/asmdecl:go_default_library", "//tools/analyzers/comparesame:go_default_library", "//tools/analyzers/cryptorand:go_default_library", "//tools/analyzers/errcheck:go_default_library", @@ -236,6 +209,53 @@ nogo( "//tools/analyzers/shadowpredecl:go_default_library", "//tools/analyzers/slicedirect:go_default_library", "//tools/analyzers/uintcast:go_default_library", + "@org_golang_x_tools//go/analysis/passes/appends:go_default_library", + "@org_golang_x_tools//go/analysis/passes/asmdecl:go_default_library", + "@org_golang_x_tools//go/analysis/passes/assign:go_default_library", + "@org_golang_x_tools//go/analysis/passes/atomic:go_default_library", + "@org_golang_x_tools//go/analysis/passes/atomicalign:go_default_library", + "@org_golang_x_tools//go/analysis/passes/bools:go_default_library", + "@org_golang_x_tools//go/analysis/passes/buildssa:go_default_library", + "@org_golang_x_tools//go/analysis/passes/buildtag:go_default_library", + # cgocall disabled + #"@org_golang_x_tools//go/analysis/passes/cgocall:go_default_library", + "@org_golang_x_tools//go/analysis/passes/copylock:go_default_library", + "@org_golang_x_tools//go/analysis/passes/ctrlflow:go_default_library", + "@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_default_library", + "@org_golang_x_tools//go/analysis/passes/defers:go_default_library", + "@org_golang_x_tools//go/analysis/passes/directive:go_default_library", + # fieldalignment disabled + #"@org_golang_x_tools//go/analysis/passes/fieldalignment:go_default_library", + "@org_golang_x_tools//go/analysis/passes/findcall:go_default_library", + "@org_golang_x_tools//go/analysis/passes/framepointer:go_default_library", + "@org_golang_x_tools//go/analysis/passes/httpmux:go_default_library", + "@org_golang_x_tools//go/analysis/passes/httpresponse:go_default_library", + "@org_golang_x_tools//go/analysis/passes/ifaceassert:go_default_library", + "@org_golang_x_tools//go/analysis/passes/inspect:go_default_library", + "@org_golang_x_tools//go/analysis/passes/loopclosure:go_default_library", + "@org_golang_x_tools//go/analysis/passes/nilfunc:go_default_library", + "@org_golang_x_tools//go/analysis/passes/nilness:go_default_library", + "@org_golang_x_tools//go/analysis/passes/pkgfact:go_default_library", + "@org_golang_x_tools//go/analysis/passes/printf:go_default_library", + "@org_golang_x_tools//go/analysis/passes/reflectvaluecompare:go_default_library", + # shadow disabled + #"@org_golang_x_tools//go/analysis/passes/shadow:go_default_library", + "@org_golang_x_tools//go/analysis/passes/shift:go_default_library", + "@org_golang_x_tools//go/analysis/passes/sigchanyzer:go_default_library", + "@org_golang_x_tools//go/analysis/passes/slog:go_default_library", + "@org_golang_x_tools//go/analysis/passes/sortslice:go_default_library", + "@org_golang_x_tools//go/analysis/passes/stdmethods:go_default_library", + "@org_golang_x_tools//go/analysis/passes/stringintconv:go_default_library", + "@org_golang_x_tools//go/analysis/passes/structtag:go_default_library", + "@org_golang_x_tools//go/analysis/passes/testinggoroutine:go_default_library", + "@org_golang_x_tools//go/analysis/passes/tests:go_default_library", + "@org_golang_x_tools//go/analysis/passes/timeformat:go_default_library", + "@org_golang_x_tools//go/analysis/passes/unmarshal:go_default_library", + "@org_golang_x_tools//go/analysis/passes/unreachable:go_default_library", + "@org_golang_x_tools//go/analysis/passes/unsafeptr:go_default_library", + "@org_golang_x_tools//go/analysis/passes/unusedresult:go_default_library", + "@org_golang_x_tools//go/analysis/passes/unusedwrite:go_default_library", + "@org_golang_x_tools//go/analysis/passes/usesgenerics:go_default_library", ] + select({ # nogo checks that fail with coverage enabled. ":coverage_enabled": [], diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go index 63f3b70bf..9338064ff 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer_test.go @@ -154,7 +154,6 @@ func TestServer_GetBeaconBlock_Altair(t *testing.T) { SyncAggregate: ðpb.SyncAggregate{SyncCommitteeBits: scBits[:], SyncCommitteeSignature: make([]byte, 96)}, }, }, - Signature: genesis.Signature, } blkRoot, err := genAltair.Block.HashTreeRoot() @@ -244,7 +243,6 @@ func TestServer_GetBeaconBlock_Bellatrix(t *testing.T) { }, }, }, - Signature: genesis.Signature, } blkRoot, err := blk.Block.HashTreeRoot() @@ -371,7 +369,6 @@ func TestServer_GetBeaconBlock_Capella(t *testing.T) { }, }, }, - Signature: genesis.Signature, } blkRoot, err := blk.Block.HashTreeRoot() @@ -483,7 +480,6 @@ func TestServer_GetBeaconBlock_Deneb(t *testing.T) { }, }, }, - Signature: genesis.Signature, } blkRoot, err := blk.Block.HashTreeRoot() diff --git a/beacon-chain/sync/blobs_test.go b/beacon-chain/sync/blobs_test.go index 6d2ba38c7..68b4b7483 100644 --- a/beacon-chain/sync/blobs_test.go +++ b/beacon-chain/sync/blobs_test.go @@ -338,7 +338,7 @@ func TestRoundTripDenebSave(t *testing.T) { require.NoError(t, undo()) }() parentRoot := [32]byte{} - c := blobsTestCase{nblocks: 10} + c := blobsTestCase{} chain, clock := defaultMockChain(t) c.chain = chain c.clock = clock diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go index ec1ff406b..9e4c7621b 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_test.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_test.go @@ -606,8 +606,6 @@ func TestBlocksFetcher_WaitForBandwidth(t *testing.T) { p1.Connect(p2) require.Equal(t, 1, len(p1.BHost.Network().Peers()), "Expected peers to be connected") req := ðpb.BeaconBlocksByRangeRequest{ - StartSlot: 100, - Step: 1, Count: 64, } diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go index 43a1b3f0d..0d44edc4c 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go @@ -1074,7 +1074,6 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) { func TestRPCBeaconBlocksByRange_FilterBlocks_PreviousRoot(t *testing.T) { req := ðpb.BeaconBlocksByRangeRequest{ StartSlot: 100, - Step: 1, Count: uint64(flags.Get().BlockBatchLimit) * 2, } diff --git a/nogo_config.json b/nogo_config.json index 851039a02..c6bc6fe85 100644 --- a/nogo_config.json +++ b/nogo_config.json @@ -190,5 +190,23 @@ "external/.*": "Third party code", "rules_go_work-.*": "Third party code" } + }, + "reflectvaluecompare": { + "exclude_files": { + "external/.*": "Third party code", + "rules_go_work-.*": "Third party code" + } + }, + "unusedwrite": { + "exclude_files": { + "external/.*": "Third party code", + "rules_go_work-.*": "Third party code" + } + }, + "stringintconv": { + "exclude_files": { + "external/.*": "Third party code", + "rules_go_work-.*": "Third party code" + } } }