Skip to content

Commit 81a9b4a

Browse files
Wondertanquantix9
andauthored
chore: upgrade to golangci-lint v2 (celestiaorg#4280)
Co-authored-by: quantix9 <quantix9@proton.me>
1 parent a99b313 commit 81a9b4a

26 files changed

Lines changed: 102 additions & 108 deletions

File tree

.github/workflows/go-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
go-version: ${{ inputs.go-version }}
4242

4343
- name: golangci-lint
44-
uses: golangci/golangci-lint-action@v6.5.0
44+
uses: golangci/golangci-lint-action@v8.0.0
4545
with:
4646
args: --timeout 10m
4747
version: latest

.golangci.yml

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,87 @@
1+
version: "2"
12
run:
23
timeout: 5m
3-
44
linters:
55
enable:
6+
- asciicheck
67
- bidichk
78
- bodyclose
8-
# - depguard as of v1.54.2, the default config throws errors on our repo
9+
- copyloopvar
910
- dogsled
1011
- dupl
11-
- errcheck
12+
- dupword
1213
- errorlint
13-
# - funlen
14-
# - gochecknoglobals
15-
# - gochecknoinits
16-
- copyloopvar
1714
- gocheckcompilerdirectives
1815
- goconst
1916
- gocritic
20-
# - gocyclo
21-
# - godox
22-
- gofmt
23-
- gofumpt
24-
- goimports
25-
# - golint - deprecated since v1.41. revive will be used instead
26-
- revive
2717
- gosec
28-
- gosimple
29-
- govet
30-
- ineffassign
31-
# - interfacer
3218
- lll
3319
- loggercheck
3420
- misspell
35-
# - maligned
3621
- nakedret
3722
- nilerr
3823
- nilnil
3924
- nolintlint
4025
- prealloc
4126
- protogetter
42-
# - scopelint - deprecated since v1.39. exportloopref will be used instead
27+
- revive
4328
- staticcheck
44-
- stylecheck
45-
- typecheck
4629
- unconvert
47-
# - unparam
48-
- unused
49-
# - whitespace
50-
# - wsl
51-
# - gocognit
5230
- wastedassign
5331
- whitespace
54-
- nolintlint
55-
- asciicheck
56-
- dupword
57-
32+
settings:
33+
dogsled:
34+
max-blank-identifiers: 3
35+
dupl:
36+
threshold: 200
37+
gosec:
38+
excludes:
39+
- G115
40+
misspell:
41+
locale: US
42+
exclusions:
43+
generated: lax
44+
presets:
45+
- comments
46+
- common-false-positives
47+
- legacy
48+
- std-error-handling
49+
rules:
50+
- linters:
51+
- gosec
52+
- revive
53+
path: _test\.go
54+
- linters:
55+
- lll
56+
source: https://
57+
paths:
58+
- third_party$
59+
- builtin$
60+
- examples$
5861
issues:
59-
exclude-rules:
60-
- path: _test\.go
61-
linters:
62-
- gosec
63-
- revive
64-
- linters:
65-
- lll
66-
source: "https://"
6762
max-same-issues: 50
68-
69-
linters-settings:
70-
gosec:
71-
excludes:
72-
- G115 # integer overflow conversion
73-
dogsled:
74-
max-blank-identifiers: 3
75-
misspell:
76-
locale: US
77-
goimports:
78-
local-prefixes: github.com/celestiaorg/celestia-node
79-
dupl:
80-
threshold: 200
81-
gofumpt:
82-
extra-rules: true
63+
formatters:
64+
enable:
65+
- gofmt
66+
- gofumpt
67+
- goimports
68+
- golines
69+
settings:
70+
gofumpt:
71+
extra-rules: true
72+
goimports:
73+
local-prefixes:
74+
- github.com/celestiaorg/celestia-node
75+
golines:
76+
# Target maximum line length.
77+
# Default: 100
78+
max-len: 200
79+
# Shorten single-line comments.
80+
# Default: false
81+
shorten-comments: true
82+
exclusions:
83+
generated: lax
84+
paths:
85+
- third_party$
86+
- builtin$
87+
- examples$

blob/blob_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestBlob(t *testing.T) {
7878

7979
newBlob := &Blob{}
8080
require.NoError(t, newBlob.UnmarshalJSON(data))
81-
require.True(t, bytes.Equal(blob[0].Blob.Data(), newBlob.Data()))
81+
require.True(t, bytes.Equal(blob[0].Data(), newBlob.Data()))
8282
require.True(t, bytes.Equal(blob[0].Commitment, newBlob.Commitment))
8383
},
8484
},

blob/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func TestBlobService_Get(t *testing.T) {
149149
require.NoError(t, err)
150150
smpls, err := service.shareGetter.GetSamples(ctx, h, []shwap.SampleCoords{idx})
151151
require.NoError(t, err)
152-
require.True(t, bytes.Equal(smpls[0].Share.ToBytes(), resultShares[shareOffset].ToBytes()),
152+
require.True(t, bytes.Equal(smpls[0].ToBytes(), resultShares[shareOffset].ToBytes()),
153153
fmt.Sprintf("issue on %d attempt. ROW:%d, COL: %d, blobIndex:%d", i, row, col, blobs[i].index),
154154
)
155155
shareOffset += libshare.SparseSharesNeeded(uint32(len(blobs[i].Data())))

core/header_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func TestMismatchedDataHash_ComputedRoot(t *testing.T) {
5757

5858
func TestBadAppVersion(t *testing.T) {
5959
header := headertest.RandExtendedHeader(t)
60-
header.RawHeader.Version.App = appconsts.LatestVersion + 1
60+
header.Version.App = appconsts.LatestVersion + 1
6161

6262
err := header.Validate()
6363
assert.Contains(t, err.Error(), fmt.Sprintf("has version %d, this node supports up to version %d. Please "+
64-
"upgrade to support new version", header.RawHeader.Version.App, appconsts.LatestVersion))
64+
"upgrade to support new version", header.Version.App, appconsts.LatestVersion))
6565
}

das/coordinator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func TestCoordinator(t *testing.T) {
229229
failedLastRun := map[uint64]int{4: 1, 8: 2, 15: 1, 16: 1, 23: 1, 42: 1, testParams.sampleFrom - 1: 1}
230230

231231
sampler := newMockSampler(testParams.sampleFrom, testParams.networkHead)
232-
sampler.checkpoint.Failed = failedLastRun
232+
sampler.Failed = failedLastRun
233233

234234
coordinator := newSamplingCoordinator(
235235
testParams.dasParams,
@@ -380,7 +380,7 @@ func (m *mockSampler) sample(ctx context.Context, h *header.ExtendedHeader) erro
380380
}
381381

382382
if height > m.NetworkHead || height < m.SampleFrom {
383-
if _, ok := m.checkpoint.Failed[height]; !ok {
383+
if _, ok := m.Failed[height]; !ok {
384384
return fmt.Errorf("header: %v out of range: %v-%v", h, m.SampleFrom, m.NetworkHead)
385385
}
386386
}
@@ -421,8 +421,8 @@ func (m *mockSampler) finalState() checkpoint {
421421
func (m *mockSampler) discover(ctx context.Context, newHeight uint64, emit listenFn) {
422422
m.lock.Lock()
423423

424-
if newHeight > m.checkpoint.NetworkHead {
425-
m.checkpoint.NetworkHead = newHeight
424+
if newHeight > m.NetworkHead {
425+
m.NetworkHead = newHeight
426426
if m.isFinished {
427427
m.finishedCh = make(chan struct{})
428428
m.isFinished = false

das/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (s *coordinatorState) unsafeStats() SamplingStats {
236236
errMsg = wstats.err.Error()
237237
}
238238
workers = append(workers, WorkerStats{
239-
JobType: wstats.job.jobType,
239+
JobType: wstats.jobType,
240240
Curr: wstats.curr,
241241
From: wstats.from,
242242
To: wstats.to,

das/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
148148
logout := log.Debugw
149149

150150
// notify network about availability of new block data (note: only full nodes can notify)
151-
if w.state.job.jobType == recentJob {
151+
if w.state.jobType == recentJob {
152152
err = w.broadcast(ctx, shrexsub.Notification{
153153
DataHash: h.DataHash.Bytes(),
154154
Height: h.Height(),

header/header.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (eh *ExtendedHeader) Hash() libhead.Hash {
9999

100100
// LastHeader returns the Hash of the last wrapped RawHeader.
101101
func (eh *ExtendedHeader) LastHeader() libhead.Hash {
102-
return libhead.Hash(eh.RawHeader.LastBlockID.Hash)
102+
return libhead.Hash(eh.LastBlockID.Hash)
103103
}
104104

105105
// Equals returns whether the hash and height of the given header match.
@@ -109,15 +109,15 @@ func (eh *ExtendedHeader) Equals(header *ExtendedHeader) bool {
109109

110110
// Validate performs *basic* validation to check for missed/incorrect fields.
111111
func (eh *ExtendedHeader) Validate() error {
112-
err := eh.RawHeader.ValidateBasic()
112+
err := eh.ValidateBasic()
113113
if err != nil {
114114
return fmt.Errorf("ValidateBasic error on RawHeader at height %d: %w", eh.Height(), err)
115115
}
116116

117-
if eh.RawHeader.Version.App == 0 || eh.RawHeader.Version.App > appconsts.LatestVersion {
117+
if eh.Version.App == 0 || eh.Version.App > appconsts.LatestVersion {
118118
return fmt.Errorf("header received at height %d has version %d, this node supports up "+
119119
"to version %d. Please upgrade to support new version. Note, 0 is not a valid version",
120-
eh.RawHeader.Height, eh.RawHeader.Version.App, appconsts.LatestVersion)
120+
eh.RawHeader.Height, eh.Version.App, appconsts.LatestVersion)
121121
}
122122

123123
err = eh.Commit.ValidateBasic()

header/headertest/fraud/testing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ func CreateFraudExtHeader(
9393
dah, err := da.NewDataAvailabilityHeader(square)
9494
require.NoError(t, err)
9595
eh.DAH = &dah
96-
eh.RawHeader.DataHash = dah.Hash()
96+
eh.DataHash = dah.Hash()
9797
return eh
9898
}

0 commit comments

Comments
 (0)