Skip to content

Commit 1e97148

Browse files
authored
all: fix inconsistent receiver name and add lint rule for it (#29974)
* .golangci.yml: enable check for consistent receiver name * beacon/light/sync: fix receiver name * core/txpool/blobpool: fix receiver name * core/types: fix receiver name * internal/ethapi: use consistent receiver name 'api' for handler object * signer/core/apitypes: fix receiver name * signer/core: use consistent receiver name 'api' for handler object * log: fix receiver name
1 parent b6f2bbd commit 1e97148

File tree

8 files changed

+237
-225
lines changed

8 files changed

+237
-225
lines changed

.golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ linters:
2323
- durationcheck
2424
- exportloopref
2525
- whitespace
26+
- revive # only certain checks enabled
2627

2728
### linters we tried and will not be using:
2829
###
@@ -38,6 +39,15 @@ linters:
3839
linters-settings:
3940
gofmt:
4041
simplify: true
42+
revive:
43+
enable-all-rules: false
44+
# here we enable specific useful rules
45+
# see https://golangci-lint.run/usage/linters/#revive for supported rules
46+
rules:
47+
- name: receiver-naming
48+
severity: warning
49+
disabled: false
50+
exclude: [""]
4151

4252
issues:
4353
exclude-files:
@@ -47,6 +57,9 @@ issues:
4757
linters:
4858
- deadcode
4959
- staticcheck
60+
- path: crypto/bn256/
61+
linters:
62+
- revive
5063
- path: internal/build/pgp.go
5164
text: 'SA1019: "golang.org/x/crypto/openpgp" is deprecated: this package is unmaintained except for security fixes.'
5265
- path: core/vm/contracts.go

beacon/light/sync/test_helpers.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,24 @@ type TestCommitteeChain struct {
173173
init bool
174174
}
175175

176-
func (t *TestCommitteeChain) CheckpointInit(bootstrap types.BootstrapData) error {
177-
t.fsp, t.nsp, t.init = bootstrap.Header.SyncPeriod(), bootstrap.Header.SyncPeriod()+2, true
176+
func (tc *TestCommitteeChain) CheckpointInit(bootstrap types.BootstrapData) error {
177+
tc.fsp, tc.nsp, tc.init = bootstrap.Header.SyncPeriod(), bootstrap.Header.SyncPeriod()+2, true
178178
return nil
179179
}
180180

181-
func (t *TestCommitteeChain) InsertUpdate(update *types.LightClientUpdate, nextCommittee *types.SerializedSyncCommittee) error {
181+
func (tc *TestCommitteeChain) InsertUpdate(update *types.LightClientUpdate, nextCommittee *types.SerializedSyncCommittee) error {
182182
period := update.AttestedHeader.Header.SyncPeriod()
183-
if period < t.fsp || period > t.nsp || !t.init {
183+
if period < tc.fsp || period > tc.nsp || !tc.init {
184184
return light.ErrInvalidPeriod
185185
}
186-
if period == t.nsp {
187-
t.nsp++
186+
if period == tc.nsp {
187+
tc.nsp++
188188
}
189189
return nil
190190
}
191191

192-
func (t *TestCommitteeChain) NextSyncPeriod() (uint64, bool) {
193-
return t.nsp, t.init
192+
func (tc *TestCommitteeChain) NextSyncPeriod() (uint64, bool) {
193+
return tc.nsp, tc.init
194194
}
195195

196196
func (tc *TestCommitteeChain) ExpInit(t *testing.T, ExpInit bool) {
@@ -199,8 +199,8 @@ func (tc *TestCommitteeChain) ExpInit(t *testing.T, ExpInit bool) {
199199
}
200200
}
201201

202-
func (t *TestCommitteeChain) SetNextSyncPeriod(nsp uint64) {
203-
t.init, t.nsp = true, nsp
202+
func (tc *TestCommitteeChain) SetNextSyncPeriod(nsp uint64) {
203+
tc.init, tc.nsp = true, nsp
204204
}
205205

206206
func (tc *TestCommitteeChain) ExpNextSyncPeriod(t *testing.T, expNsp uint64) {

core/txpool/blobpool/blobpool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (bc *testBlockChain) CurrentFinalBlock() *types.Header {
143143
}
144144
}
145145

146-
func (bt *testBlockChain) GetBlock(hash common.Hash, number uint64) *types.Block {
146+
func (bc *testBlockChain) GetBlock(hash common.Hash, number uint64) *types.Block {
147147
return nil
148148
}
149149

core/types/transaction_signing.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,11 @@ func (s EIP155Signer) Hash(tx *Transaction) common.Hash {
459459
// homestead rules.
460460
type HomesteadSigner struct{ FrontierSigner }
461461

462-
func (s HomesteadSigner) ChainID() *big.Int {
462+
func (hs HomesteadSigner) ChainID() *big.Int {
463463
return nil
464464
}
465465

466-
func (s HomesteadSigner) Equal(s2 Signer) bool {
466+
func (hs HomesteadSigner) Equal(s2 Signer) bool {
467467
_, ok := s2.(HomesteadSigner)
468468
return ok
469469
}
@@ -486,11 +486,11 @@ func (hs HomesteadSigner) Sender(tx *Transaction) (common.Address, error) {
486486
// frontier rules.
487487
type FrontierSigner struct{}
488488

489-
func (s FrontierSigner) ChainID() *big.Int {
489+
func (fs FrontierSigner) ChainID() *big.Int {
490490
return nil
491491
}
492492

493-
func (s FrontierSigner) Equal(s2 Signer) bool {
493+
func (fs FrontierSigner) Equal(s2 Signer) bool {
494494
_, ok := s2.(FrontierSigner)
495495
return ok
496496
}

0 commit comments

Comments
 (0)