Skip to content
Open
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
27 changes: 19 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,28 @@ linters:
# Init functions are used by loggers throughout the codebase.
- gochecknoinits

# Deprecated linters. See https://golangci-lint.run/usage/linters/.
- bodyclose
# contextcheck requires threading context.Context through many existing
# function signatures (including test harnesses), so we leave it off for
# now.
- contextcheck
- nilerr
- noctx
- rowserrcheck
- sqlclosecheck

# tparallel requires adding t.Parallel() to a large number of existing
# subtests, which can surface shared-state races. Disabled until we can
# address it carefully.
- tparallel

# unparam has a sizeable backlog of unused parameters to clean up before it
# can be enabled.
- unparam
- wastedassign

# nilerr is too noisy for our code base: most reports are intentional error
# swallowing (documented with comments) or false positives where a boolean
# check is mistaken for an error check.
- nilerr

# noctx would only flag a couple of interface methods and a test helper that
# have no context to thread through, so it adds little value for now.
- noctx

# Disable whitespace linters as it has conflict rules against our
# contribution guidelines.
Expand Down Expand Up @@ -114,7 +126,6 @@ linters:
- testifylint
- perfsprint
- inamedparam
- copyloopvar
- tagalign
- protogetter
- revive
Expand Down
1 change: 0 additions & 1 deletion aliasmgr/aliasmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ func TestGetNextScid(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
nextScid := getNextScid(test.current)
require.Equal(t, test.expected, nextScid)
Expand Down
1 change: 0 additions & 1 deletion amp/derivation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ var sharerTests = []sharerTest{
// receiver, produce identical child hashes and preimages as the sender.
func TestSharer(t *testing.T) {
for _, test := range sharerTests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 0 additions & 3 deletions autopilot/betweenness_centrality_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestBetweennessCentralityEmptyGraph(t *testing.T) {
)

for _, chanGraph := range chanGraphs {
chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")

Expand Down Expand Up @@ -83,7 +82,6 @@ func TestBetweennessCentralityWithNonEmptyGraph(t *testing.T) {

for _, numWorkers := range workers {
for _, chanGraph := range chanGraphs {
chanGraph := chanGraph
numWorkers := numWorkers
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")
Expand All @@ -110,7 +108,6 @@ func TestBetweennessCentralityWithNonEmptyGraph(t *testing.T) {
require.NoError(t1, err)

for _, expected := range tests {
expected := expected
centrality := metric.GetMetric(
expected.normalize,
)
Expand Down
4 changes: 0 additions & 4 deletions autopilot/prefattach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func TestPrefAttachmentSelectEmptyGraph(t *testing.T) {
}

for _, chanGraph := range chanGraphs {
chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")

Expand Down Expand Up @@ -128,7 +127,6 @@ func TestPrefAttachmentSelectTwoVertexes(t *testing.T) {
)

for _, chanGraph := range chanGraphs {
chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")

Expand Down Expand Up @@ -215,7 +213,6 @@ func TestPrefAttachmentSelectGreedyAllocation(t *testing.T) {
)

for _, chanGraph := range chanGraphs {
chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")

Expand Down Expand Up @@ -328,7 +325,6 @@ func TestPrefAttachmentSelectSkipNodes(t *testing.T) {
)

for _, chanGraph := range chanGraphs {
chanGraph := chanGraph
graph, err := chanGraph.genFunc(t)
require.NoError(t, err, "unable to create graph")

Expand Down
1 change: 0 additions & 1 deletion autopilot/top_centrality_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func TestTopCentrality(t *testing.T) {
}

for _, chanGraph := range chanGraphs {
chanGraph := chanGraph

success := t.Run(chanGraph.name, func(t1 *testing.T) {
t1.Parallel()
Expand Down
1 change: 0 additions & 1 deletion build/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func TestParseAndSetDebugLevels(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.name, func(t *testing.T) {
m := &mockSubLogger{
subLogLevels: make(map[string]string),
Expand Down
2 changes: 0 additions & 2 deletions chainntnfs/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,6 @@ func (m *MempoolNotifier) notifySpent(spentInputs inputsWithTx) {

// Iterate the spent inputs to notify the subscribers concurrently.
for op, tx := range spentInputs {
op, tx := op, tx

m.wg.Add(1)
go notifyAll(tx, op)
}
Expand Down
13 changes: 9 additions & 4 deletions chainntnfs/txnotifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func TestTxNotifierRegistrationValidation(t *testing.T) {
}

for _, testCase := range testCases {
testCase := testCase
success := t.Run(testCase.name, func(t *testing.T) {
hintCache := newMockHintCache()
n := chainntnfs.NewTxNotifier(
Expand Down Expand Up @@ -1943,14 +1942,18 @@ func TestTxNotifierConfirmHintCache(t *testing.T) {
// the height hints should remain unchanged. This simulates blocks
// confirming while the historical dispatch is processing the
// registration.
hint, err := hintCache.QueryConfirmHint(ntfn1.HistoricalDispatch.ConfRequest)
_, err = hintCache.QueryConfirmHint(
ntfn1.HistoricalDispatch.ConfRequest,
)
if err != chainntnfs.ErrConfirmHintNotFound {
t.Fatalf("unexpected error when querying for height hint "+
"want: %v, got %v",
chainntnfs.ErrConfirmHintNotFound, err)
}

hint, err = hintCache.QueryConfirmHint(ntfn2.HistoricalDispatch.ConfRequest)
_, err = hintCache.QueryConfirmHint(
ntfn2.HistoricalDispatch.ConfRequest,
)
if err != chainntnfs.ErrConfirmHintNotFound {
t.Fatalf("unexpected error when querying for height hint "+
"want: %v, got %v",
Expand Down Expand Up @@ -1979,7 +1982,9 @@ func TestTxNotifierConfirmHintCache(t *testing.T) {
// Now that both notifications are waiting at tip for confirmations,
// they should have their height hints updated to the latest block
// height.
hint, err = hintCache.QueryConfirmHint(ntfn1.HistoricalDispatch.ConfRequest)
hint, err := hintCache.QueryConfirmHint(
ntfn1.HistoricalDispatch.ConfRequest,
)
require.NoError(t, err, "unable to query for hint")
if hint != tx1Height {
t.Fatalf("expected hint %d, got %d",
Expand Down
2 changes: 0 additions & 2 deletions chanacceptor/acceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ func (c *channelAcceptorCtx) queryAndAssert(queries map[*lnwire.OpenChannel]*Cha
)

for request, expected := range queries {
request := request
expected := expected

go func() {
resp := c.acceptor.Accept(&ChannelAcceptRequest{
Expand Down
1 change: 0 additions & 1 deletion chanacceptor/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func TestMergeResponse(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
resp, err := mergeResponse(test.current, test.new)
Expand Down
1 change: 0 additions & 1 deletion chanacceptor/rpcacceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func TestValidateAcceptorResponse(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
// Create an acceptor, everything can be nil because
Expand Down
1 change: 0 additions & 1 deletion chanbackup/backupfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ func TestCreateArchiveFile(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
defer os.RemoveAll(archiveDir)
if tc.setup != nil {
Expand Down
2 changes: 0 additions & 2 deletions chanfitness/chanevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ func TestGetOnlinePeriod(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -545,7 +544,6 @@ func TestUptime(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
score := &peerLog{
Expand Down
1 change: 0 additions & 1 deletion chanfitness/chaneventstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestStartStoreError(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
clock := clock.NewTestClock(testNow)
Expand Down
2 changes: 0 additions & 2 deletions chanfitness/rate_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func TestGetRateLimit(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -91,7 +90,6 @@ func TestCooldownFlapCount(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
t.Parallel()
Expand Down
5 changes: 0 additions & 5 deletions channeldb/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ func TestOptionalShutdown(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
fullDB, err := MakeTestDB(t)
Expand Down Expand Up @@ -1325,7 +1324,6 @@ func TestShutdownInfo(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -1513,7 +1511,6 @@ func TestCloseInitiator(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -1634,7 +1631,6 @@ func TestHasChanStatus(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
c := &OpenChannel{
Expand Down Expand Up @@ -1817,7 +1813,6 @@ func TestHTLCsExtraData(t *testing.T) {
}

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

t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
Expand Down
1 change: 0 additions & 1 deletion channeldb/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ func TestFetchChannels(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
t.Parallel()
Expand Down
4 changes: 0 additions & 4 deletions channeldb/height_hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func (c *HeightHintCache) CommitSpendHint(height uint32,
}

for _, spendRequest := range spendRequests {
spendRequest := spendRequest
spendHintKey, err := spendHintKey(&spendRequest)
if err != nil {
return err
Expand Down Expand Up @@ -161,7 +160,6 @@ func (c *HeightHintCache) PurgeSpendHint(
}

for _, spendRequest := range spendRequests {
spendRequest := spendRequest
spendHintKey, err := spendHintKey(&spendRequest)
if err != nil {
return err
Expand Down Expand Up @@ -198,7 +196,6 @@ func (c *HeightHintCache) CommitConfirmHint(height uint32,
}

for _, confRequest := range confRequests {
confRequest := confRequest
confHintKey, err := confHintKey(&confRequest)
if err != nil {
return err
Expand Down Expand Up @@ -269,7 +266,6 @@ func (c *HeightHintCache) PurgeConfirmHint(
}

for _, confRequest := range confRequests {
confRequest := confRequest
confHintKey, err := confHintKey(&confRequest)
if err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions channeldb/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,6 @@ func (k *kvInvoiceUpdater) storeAddHtlcsUpdate() error {
// As we don't update the settle index above for AMP invoices, we'll do
// it here for each sub-AMP invoice that was settled.
for settledSetID := range k.settledSetIDs {
settledSetID := settledSetID
err := k.setSettleMetaFields(&settledSetID)
if err != nil {
return err
Expand Down Expand Up @@ -1862,7 +1861,6 @@ func ampStateEncoder(w io.Writer, val interface{}, buf *[8]byte) error {
// inner length prefix.
for setID, ampState := range *v {
setID := [32]byte(setID)
ampState := ampState

htlcState := uint8(ampState.State)
settleDate := ampState.SettleDate
Expand Down
4 changes: 2 additions & 2 deletions channeldb/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ func TestApplyOptionalVersions(t *testing.T) {
require.Equal(t, 0, migrateCount, "expected no migration")

// Check the optional meta is not updated.
om, err := db.fetchOptionalMeta()
_, err = db.fetchOptionalMeta()
require.NoError(t, err, "error getting optional meta")

// Enable all optional migrations.
Expand All @@ -563,7 +563,7 @@ func TestApplyOptionalVersions(t *testing.T) {
)

// Fetch the updated optional meta.
om, err = db.fetchOptionalMeta()
om, err := db.fetchOptionalMeta()
require.NoError(t, err, "error getting optional meta")

// Verify that the optional meta is updated as expected.
Expand Down
1 change: 0 additions & 1 deletion channeldb/migration/create_tlb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestCreateTLB(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
migtest.ApplyMigration(
t,
Expand Down
1 change: 0 additions & 1 deletion channeldb/migration12/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func genAfterMigration(afterBytes []byte) func(kvdb.RwTx) error {
// final struct, but verifies that the field is properly removed.
func TestTLVInvoiceMigration(t *testing.T) {
for _, test := range migrationTests {
test := test
t.Run(test.name, func(t *testing.T) {
migtest.ApplyMigration(
t,
Expand Down
1 change: 0 additions & 1 deletion channeldb/migration16/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func TestMigrateSequenceIndex(t *testing.T) {
}

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

t.Run(test.name, func(t *testing.T) {
// Before the migration we have a payments bucket.
Expand Down
1 change: 0 additions & 1 deletion channeldb/migration23/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func TestMigrateHtlcAttempts(t *testing.T) {
}

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

migtest.ApplyMigration(
t,
Expand Down
Loading
Loading