Skip to content

Commit 98fece4

Browse files
authored
Merge pull request #993 from hieblmi/asciicheck
gomod: update to Go 1.24.6 and `golangci-lint` v2
2 parents f54d580 + 38a4496 commit 98fece4

40 files changed

+554
-504
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020

2121
# If you change this value, please change it in the following files as well:
2222
# /Dockerfile
23-
GO_VERSION: 1.24.0
23+
GO_VERSION: 1.24.6
2424

2525
jobs:
2626
########################

.golangci.yml

Lines changed: 111 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,131 @@
1+
version: "2"
12
run:
3+
go: "1.24"
4+
25
# timeout for analysis
36
timeout: 4m
4-
5-
go: "1.23"
6-
7-
linters-settings:
8-
govet:
9-
# Don't report about shadowed variables
10-
shadowing: false
11-
12-
gofmt:
13-
# simplify code: gofmt with `-s` option, true by default
14-
simplify: true
15-
16-
tagliatelle:
17-
case:
18-
rules:
19-
json: snake
20-
21-
whitespace:
22-
multi-func: true
23-
multi-if: true
24-
25-
gosec:
26-
excludes:
27-
- G402 # Look for bad TLS connection settings.
28-
- G306 # Poor file permissions used when writing to a new file.
29-
- G115 # Integer overflow conversion.
30-
31-
staticcheck:
32-
checks: [ "-SA1019" ]
337

348
linters:
35-
enable-all: true
9+
default: all
3610
disable:
37-
# Global variables are used in many places throughout the code base.
38-
- gochecknoglobals
39-
40-
# Some lines are over 80 characters on purpose and we don't want to make them
41-
# even longer by marking them as 'nolint'.
42-
- lll
43-
44-
# We want to allow short variable names.
45-
- varnamelen
46-
47-
# We want to allow TODOs.
48-
- godox
49-
50-
# We have long functions, especially in tests. Moving or renaming those would
51-
# trigger funlen problems that we may not want to solve at that time.
52-
- funlen
53-
54-
# Disable for now as we haven't yet tuned the sensitivity to our codebase
55-
# yet. Enabling by default for example, would also force new contributors to
56-
# potentially extensively refactor code, when they want to smaller change to
57-
# land.
58-
- gocyclo
59-
- gocognit
11+
- containedctx
12+
- contextcheck
6013
- cyclop
61-
62-
# Instances of table driven tests that don't pre-allocate shouldn't trigger
63-
# the linter.
64-
- prealloc
65-
66-
# Init functions are used by loggers throughout the codebase.
67-
- gochecknoinits
68-
69-
# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
14+
- depguard
15+
- dogsled
16+
- err113
17+
- errname
7018
- errorlint
71-
72-
# New linters that need a code adjustment first.
73-
- wrapcheck
74-
- nolintlint
75-
- paralleltest
76-
- tparallel
77-
- testpackage
78-
- gofumpt
19+
- exhaustive
20+
- exhaustruct
21+
- forcetypeassert
22+
- funlen
23+
- gochecknoglobals
24+
- gochecknoinits
25+
- gocognit
26+
- gocyclo
27+
- godox
7928
- gomoddirectives
29+
- inamedparam
30+
- interfacebloat
31+
- intrange
8032
- ireturn
8133
- maintidx
82-
- nlreturn
83-
- dogsled
84-
- gci
85-
- containedctx
86-
- contextcheck
87-
- errname
88-
- err113
8934
- mnd
90-
- noctx
9135
- nestif
92-
- wsl
93-
- exhaustive
94-
- forcetypeassert
9536
- nilerr
9637
- nilnil
97-
- stylecheck
98-
- thelper
99-
- revive
100-
- tagalign
101-
- depguard
102-
- interfacebloat
103-
- inamedparam
104-
- intrange
38+
- nlreturn
39+
- noctx
40+
- nolintlint
41+
- paralleltest
10542
- perfsprint
43+
- prealloc
10644
- protogetter
45+
- revive
46+
- tagalign
10747
- testifylint
108-
109-
# Additions compared to LND
110-
- exhaustruct
111-
48+
- testpackage
49+
- thelper
50+
- tparallel
51+
- varnamelen
52+
- wrapcheck
53+
- wsl
54+
- funcorder
55+
- wsl_v5
56+
- noinlineerr
57+
settings:
58+
gosec:
59+
excludes:
60+
- G402
61+
- G306
62+
- G115
63+
staticcheck:
64+
checks:
65+
- -SA1019
66+
tagliatelle:
67+
case:
68+
rules:
69+
json: snake
70+
whitespace:
71+
multi-if: true
72+
multi-func: true
73+
exclusions:
74+
generated: lax
75+
presets:
76+
- comments
77+
- common-false-positives
78+
- legacy
79+
- std-error-handling
80+
rules:
81+
- linters:
82+
- forbidigo
83+
- gosec
84+
- unparam
85+
path: _test\.go
86+
- linters:
87+
- gosec
88+
path: _mock\.go
89+
- linters:
90+
- errcheck
91+
- forbidigo
92+
path: cmd/loopd/*
93+
- linters:
94+
- forbidigo
95+
path: loopd/*
96+
- linters:
97+
- errcheck
98+
- forbidigo
99+
path: cmd/loop/*
100+
- linters:
101+
- forbidigo
102+
path: fsm/stateparser/*
103+
- linters:
104+
- lll
105+
path: loopd/config.go
106+
- linters:
107+
- lll
108+
path: loopdb/*
109+
paths:
110+
- \.pb\.go$
111+
- \.pb\.gw\.go$
112+
- third_party$
113+
- builtin$
114+
- examples$
112115
issues:
113-
# Only show newly introduced problems.
114116
new-from-rev: 36838cf7f464cf73b0201798063b2caffeae4250
115-
116-
exclude-files:
117-
- "\\.pb\\.go$"
118-
- "\\.pb\\.gw\\.go$"
119-
120-
exclude-rules:
121-
# Allow fmt.Printf() in test files
122-
- path: _test\.go
123-
linters:
124-
- forbidigo
125-
- unparam
126-
- gosec
127-
- path: _mock\.go
128-
linters:
129-
- gosec
130-
131-
# Allow fmt.Printf() in loopd
132-
- path: cmd/loopd/*
133-
linters:
134-
- forbidigo
135-
- errcheck
136-
- path: loopd/*
137-
linters:
138-
- forbidigo
139-
140-
# Allow fmt.Printf() in loop
141-
- path: cmd/loop/*
142-
linters:
143-
- forbidigo
144-
- errcheck
145-
146-
# Allow fmt.Printf() in stateparser
147-
- path: fsm/stateparser/*
148-
linters:
149-
- forbidigo
117+
formatters:
118+
enable:
119+
- gofmt
120+
- goimports
121+
settings:
122+
gofmt:
123+
simplify: true
124+
exclusions:
125+
generated: lax
126+
paths:
127+
- \.pb\.go$
128+
- \.pb\.gw\.go$
129+
- third_party$
130+
- builtin$
131+
- examples$

client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ var (
9393
// Client performs the client side part of swaps. This interface exists to be
9494
// able to implement a stub.
9595
type Client struct {
96+
clientConfig
97+
9698
started uint32 // To be used atomically.
9799
errChan chan error
98100

@@ -107,8 +109,6 @@ type Client struct {
107109

108110
resumeReady chan struct{}
109111
wg sync.WaitGroup
110-
111-
clientConfig
112112
}
113113

114114
// ClientConfig is the exported configuration structure that is required to

cmd/loop/instantout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ func instantOut(ctx *cli.Context) error {
187187
DestAddr: ctx.String("addr"),
188188
},
189189
)
190-
191190
if err != nil {
192191
return err
193192
}
@@ -228,5 +227,6 @@ func listInstantOuts(ctx *cli.Context) error {
228227
}
229228

230229
printRespJSON(resp)
230+
231231
return nil
232232
}

cmd/loop/loopin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ func loopIn(ctx *cli.Context) error {
207207

208208
fmt.Printf("Swap initiated\n")
209209
fmt.Printf("ID: %v\n", resp.Id)
210+
210211
if resp.HtlcAddressP2Tr != "" {
211212
fmt.Printf("HTLC address (P2TR): %v\n", resp.HtlcAddressP2Tr)
212213
} else {

cmd/loop/loopout.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ func loopOut(ctx *cli.Context) error {
176176
"address to sweep the loop amount to")
177177
}
178178

179-
var destAddr string
180-
var account string
179+
var (
180+
destAddr string
181+
account string
182+
)
181183
switch {
182184
case ctx.IsSet("addr"):
183185
destAddr = ctx.String("addr")

cmd/loop/staticaddr.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
417417
if len(utxos) == 0 {
418418
return nil, fmt.Errorf("no utxos specified")
419419
}
420+
420421
for _, utxo := range utxos {
421422
outpoint, err := NewProtoOutPoint(utxo)
422423
if err != nil {

cost_migration.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
2525
paymentFees map[lntypes.Hash]lnwire.MilliSatoshi) (loopdb.SwapCost,
2626
error) {
2727

28-
// First make sure that this swap is actually finished.
28+
// First, make sure that this swap is actually finished.
2929
if loopOutSwap.State().State.IsPending() {
3030
return loopdb.SwapCost{}, fmt.Errorf("swap is not yet finished")
3131
}
@@ -41,8 +41,8 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
4141
}
4242

4343
// The swap hash is given and we don't need to get it from the
44-
// swap invoice, however we'll decode it anyway to get the invoice amount
45-
// that was paid in case we don't have the payment anymore.
44+
// swap invoice, however we'll decode it anyway to get the invoice
45+
// amount that was paid in case we don't have the payment anymore.
4646
_, _, swapHash, swapPaymentAmount, err := swap.DecodeInvoice(
4747
params, loopOutSwap.Contract.SwapInvoice,
4848
)
@@ -195,6 +195,6 @@ func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices,
195195
return err
196196
}
197197

198-
// Finally mark the migration as done.
198+
// Finally, mark the migration as done.
199199
return db.SetMigration(ctx, costMigrationID)
200200
}

executor.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,14 @@ type executorConfig struct {
4242
}
4343

4444
// executor is responsible for executing swaps.
45-
//
46-
// TODO(roasbeef): rename to SubSwapper.
4745
type executor struct {
46+
sync.Mutex
47+
executorConfig
48+
4849
wg sync.WaitGroup
4950
newSwaps chan genericSwap
5051
currentHeight uint32
5152
ready chan struct{}
52-
53-
sync.Mutex
54-
55-
executorConfig
5653
}
5754

5855
// newExecutor returns a new swap executor instance.
@@ -80,7 +77,6 @@ func (s *executor) run(mainCtx context.Context,
8077
for {
8178
blockEpochChan, blockErrorChan, err =
8279
s.lnd.ChainNotifier.RegisterBlockEpochNtfn(mainCtx)
83-
8480
if err == nil {
8581
break
8682
}

fsm/fsm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func NewStateMachine(states States, observerSize int) *StateMachine {
138138
func NewStateMachineWithState(states States, current StateType,
139139
observerSize int) *StateMachine {
140140

141-
observers := []Observer{}
141+
var observers []Observer
142142
var defaultObserver *CachedObserver
143143

144144
if observerSize > 0 {

0 commit comments

Comments
 (0)