Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update compile-time dependency of lnd to 0.19.0, update linter #894

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 114 additions & 118 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
run:
# timeout for analysis
deadline: 4m

skip-files:
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
timeout: 4m

go: "1.23"

linters-settings:
govet:
# Don't report about shadowed variables
check-shadowing: false
shadowing: false

gofmt:
# simplify code: gofmt with `-s` option, true by default
Expand All @@ -28,126 +26,124 @@ linters-settings:
excludes:
- G402 # Look for bad TLS connection settings.
- G306 # Poor file permissions used when writing to a new file.
- G115 # Integer overflow conversion.

staticcheck:
go: "1.18"
checks: ["-SA1019"]
staticcheck:
checks: [ "-SA1019" ]

linters:
enable-all: true
disable:
# Global variables are used in many places throughout the code base.
- gochecknoglobals

# Some lines are over 80 characters on purpose and we don't want to make them
# even longer by marking them as 'nolint'.
- lll

# We want to allow short variable names.
- varnamelen

# We want to allow TODOs.
- godox

# We have long functions, especially in tests. Moving or renaming those would
# trigger funlen problems that we may not want to solve at that time.
- funlen

# Disable for now as we haven't yet tuned the sensitivity to our codebase
# yet. Enabling by default for example, would also force new contributors to
# potentially extensively refactor code, when they want to smaller change to
# land.
- gocyclo
- gocognit
- cyclop

# Instances of table driven tests that don't pre-allocate shouldn't trigger
# the linter.
- prealloc

# Init functions are used by loggers throughout the codebase.
- gochecknoinits

# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
- errorlint

# Deprecated linters. See https://golangci-lint.run/usage/linters/.
- interfacer
- golint
- maligned
- scopelint
- varcheck
- structcheck
- deadcode

# New linters that need a code adjustment first.
- wrapcheck
- nolintlint
- paralleltest
- tparallel
- testpackage
- gofumpt
- gomoddirectives
- ireturn
- maintidx
- nlreturn
- dogsled
- gci
- containedctx
- contextcheck
- errname
- exhaustivestruct
- goerr113
- gomnd
- ifshort
- noctx
- nestif
- wsl
- exhaustive
- forcetypeassert
- nilerr
- nilnil
- stylecheck
- thelper
- revive
- tagalign
- depguard
- nosnakecase
- interfacebloat

# Additions compared to LND
- exhaustruct
# Global variables are used in many places throughout the code base.
- gochecknoglobals

# Some lines are over 80 characters on purpose and we don't want to make them
# even longer by marking them as 'nolint'.
- lll

# We want to allow short variable names.
- varnamelen

# We want to allow TODOs.
- godox

# We have long functions, especially in tests. Moving or renaming those would
# trigger funlen problems that we may not want to solve at that time.
- funlen

# Disable for now as we haven't yet tuned the sensitivity to our codebase
# yet. Enabling by default for example, would also force new contributors to
# potentially extensively refactor code, when they want to smaller change to
# land.
- gocyclo
- gocognit
- cyclop

# Instances of table driven tests that don't pre-allocate shouldn't trigger
# the linter.
- prealloc

# Init functions are used by loggers throughout the codebase.
- gochecknoinits

# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
- errorlint

# New linters that need a code adjustment first.
- wrapcheck
- nolintlint
- paralleltest
- tparallel
- testpackage
- gofumpt
- gomoddirectives
- ireturn
- maintidx
- nlreturn
- dogsled
- gci
- containedctx
- contextcheck
- errname
- err113
- mnd
- noctx
- nestif
- wsl
- exhaustive
- forcetypeassert
- nilerr
- nilnil
- stylecheck
- thelper
- revive
- tagalign
- depguard
- interfacebloat
- inamedparam
- intrange
- perfsprint
- protogetter
- testifylint

# Additions compared to LND
- exhaustruct

issues:
# Only show newly introduced problems.
new-from-rev: 36838cf7f464cf73b0201798063b2caffeae4250

exclude-rules:

# Allow fmt.Printf() in test files
- path: _test\.go
linters:
- forbidigo
- unparam
- gosec
- path: _mock\.go
linters:
- gosec

# Allow fmt.Printf() in loopd
- path: cmd/loopd/*
linters:
- forbidigo
- path: loopd/*
linters:
- forbidigo

# Allow fmt.Printf() in loop
- path: cmd/loop/*
linters:
- forbidigo
exclude-files:
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"

# Allow fmt.Printf() in stateparser
- path: fsm/stateparser/*
linters:
- forbidigo
exclude-rules:
# Allow fmt.Printf() in test files
- path: _test\.go
linters:
- forbidigo
- unparam
- gosec
- path: _mock\.go
linters:
- gosec

# Allow fmt.Printf() in loopd
- path: cmd/loopd/*
linters:
- forbidigo
- errcheck
- path: loopd/*
linters:
- forbidigo

# Allow fmt.Printf() in loop
- path: cmd/loop/*
linters:
- forbidigo
- errcheck

# Allow fmt.Printf() in stateparser
- path: fsm/stateparser/*
linters:
- forbidigo
4 changes: 0 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) {
swaps := make([]*SwapInfo, 0, len(loopInSwaps)+len(loopOutSwaps))

for _, swp := range loopOutSwaps {
swp := swp

swapInfo := &SwapInfo{
SwapType: swap.TypeOut,
SwapContract: swp.Contract.SwapContract,
Expand Down Expand Up @@ -358,8 +356,6 @@ func (s *Client) FetchSwaps(ctx context.Context) ([]*SwapInfo, error) {
}

for _, swp := range loopInSwaps {
swp := swp

swapInfo := &SwapInfo{
SwapType: swap.TypeIn,
SwapContract: swp.Contract.SwapContract,
Expand Down
4 changes: 0 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ func TestLoopOutResume(t *testing.T) {
}

for _, version := range storedVersion {
version := version

t.Run(version.String(), func(t *testing.T) {
t.Run("not expired", func(t *testing.T) {
testLoopOutResume(
Expand Down Expand Up @@ -443,8 +441,6 @@ func TestWrapGrpcError(t *testing.T) {
}

for _, testCase := range tests {
testCase := testCase

t.Run(testCase.name, func(t *testing.T) {
err := wrapGrpcError("", testCase.original)
require.Error(t, err, "test only expects errors")
Expand Down
4 changes: 2 additions & 2 deletions cmd/loop/terms.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func terms(ctx *cli.Context) error {
}
defer cleanup()

printAmountRange := func(min, max int64) {
printAmountRange := func(minAmt, maxAmt int64) {
fmt.Printf("Amount: %d - %d\n",
btcutil.Amount(min), btcutil.Amount(max),
btcutil.Amount(minAmt), btcutil.Amount(maxAmt),
)
}

Expand Down
6 changes: 0 additions & 6 deletions fsm/example_fsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ func TestExampleFSM(t *testing.T) {
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
ctxb := context.Background()
respondChan := make(chan string, 1)
Expand Down Expand Up @@ -192,8 +190,6 @@ func TestExampleFSMFlow(t *testing.T) {
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
exampleContext, cachedObserver := getTestContext()
ctxb := context.Background()
Expand Down Expand Up @@ -268,8 +264,6 @@ func TestObserverAsyncWait(t *testing.T) {
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
service := &mockService{
respondChan: make(chan bool),
Expand Down
2 changes: 1 addition & 1 deletion fsm/log.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fsm

import (
"github.com/btcsuite/btclog"
"github.com/btcsuite/btclog/v2"
"github.com/lightningnetwork/lnd/build"
)

Expand Down
Loading