Fix staticcheck violations (#13301)

* Fix violations of sa2002

* Fix violations of sa4005

* Fix violations of sa4010

* Fix violations for sa4023

* Comment on commented static checks
This commit is contained in:
Preston Van Loon 2023-12-08 07:07:52 -06:00 committed by GitHub
parent f537a98fcd
commit ff99616833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 16 deletions

View File

@ -104,7 +104,7 @@ STATICCHECK_ANALYZERS = [
"sa1016",
"sa1017",
"sa1018",
# "sa1019",
# "sa1019", # TODO: Fix all uses of deprecated things.
"sa1020",
"sa1021",
"sa1023",
@ -117,7 +117,7 @@ STATICCHECK_ANALYZERS = [
"sa1030",
"sa2000",
"sa2001",
# "sa2002",
"sa2002",
"sa2003",
"sa3000",
"sa3001",
@ -125,11 +125,11 @@ STATICCHECK_ANALYZERS = [
"sa4001",
"sa4003",
"sa4004",
# "sa4005",
# "sa4006",
"sa4005",
# "sa4006", # TODO: Fix violations of unused arguments.
"sa4008",
"sa4009",
# "sa4010",
"sa4010",
"sa4011",
"sa4012",
"sa4013",
@ -142,7 +142,7 @@ STATICCHECK_ANALYZERS = [
"sa4020",
"sa4021",
"sa4022",
# "sa4023",
"sa4023",
"sa4024",
"sa4025",
"sa4026",

View File

@ -314,7 +314,10 @@ func (dc *DepositCache) PruneProofs(ctx context.Context, untilDepositIndex int64
// Deposits returns the cached internal deposit tree.
func (fd *FinalizedDeposits) Deposits() cache.MerkleTree {
return fd.deposits
if fd.deposits != nil {
return fd.deposits
}
return nil
}
// MerkleTrieIndex represents the last finalized index in

View File

@ -477,11 +477,9 @@ func TestAttestationRewards(t *testing.T) {
require.NoError(t, st.SetSlot(params.BeaconConfig().SlotsPerEpoch*3-1))
validators := make([]*eth.Validator, 0, valCount)
balances := make([]uint64, 0, valCount)
secretKeys := make([]bls.SecretKey, 0, valCount)
for i := 0; i < valCount; i++ {
blsKey, err := bls.RandKey()
require.NoError(t, err)
secretKeys = append(secretKeys, blsKey)
validators = append(validators, &eth.Validator{
PublicKey: blsKey.PublicKey().Marshal(),
ExitEpoch: params.BeaconConfig().FarFutureEpoch,

View File

@ -212,7 +212,7 @@ func (r *testRunner) testDepositsAndTx(ctx context.Context, g *errgroup.Group,
// for further deposit testing.
err := r.depositor.SendAndMine(ctx, minGenesisActiveCount, int(e2e.DepositCount), e2etypes.PostGenesisDepositBatch, false)
if err != nil {
r.t.Fatal(err)
r.t.Error(err)
}
}
r.testTxGeneration(ctx, g, keystorePath, []e2etypes.ComponentRunner{})

View File

@ -16,19 +16,19 @@ type MockProtector struct {
}
// CheckAttestationSafety returns bool with allow attestation value.
func (mp MockProtector) CheckAttestationSafety(_ context.Context, _ *eth.IndexedAttestation) bool {
mp.VerifyAttestationCalled = true // skipcq: RVV-B0006
func (mp *MockProtector) CheckAttestationSafety(_ context.Context, _ *eth.IndexedAttestation) bool {
mp.VerifyAttestationCalled = true
return mp.AllowAttestation
}
// CheckBlockSafety returns bool with allow block value.
func (mp MockProtector) CheckBlockSafety(_ context.Context, _ *eth.SignedBeaconBlockHeader) bool {
mp.VerifyBlockCalled = true // skipcq: RVV-B0006
func (mp *MockProtector) CheckBlockSafety(_ context.Context, _ *eth.SignedBeaconBlockHeader) bool {
mp.VerifyBlockCalled = true
return mp.AllowBlock
}
// Status returns nil.
func (mp MockProtector) Status() error {
mp.StatusCalled = true // skipcq: RVV-B0006
func (mp *MockProtector) Status() error {
mp.StatusCalled = true
return nil
}