Merge pull request #6270 from guggero/enable-whitespace-linter
ci: enable whitespace linter
This commit is contained in:
18 files changed
+39
-27
No files matched your search
@@ -83,10 +83,6 @@ linters:
|
|||||||
# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
|
# Causes stack overflow, see https://github.com/polyfloyd/go-errorlint/issues/19.
|
||||||
- errorlint
|
- errorlint
|
||||||
|
|
||||||
# Has an issue (https://github.com/ultraware/whitespace/issues/6) but will
|
|
||||||
# want to enable this in the future.
|
|
||||||
- whitespace
|
|
||||||
|
|
||||||
# Deprecated linters. See https://golangci-lint.run/usage/linters/.
|
# Deprecated linters. See https://golangci-lint.run/usage/linters/.
|
||||||
- interfacer
|
- interfacer
|
||||||
- golint
|
- golint
|
||||||
|
|||||||
@@ -1463,7 +1463,6 @@ func (d *DB) InvoicesSettledSince(sinceSettleIndex uint64) ([]Invoice, error) {
|
|||||||
seqNo, indexValue := invoiceCursor.Next()
|
seqNo, indexValue := invoiceCursor.Next()
|
||||||
|
|
||||||
for ; seqNo != nil && bytes.Compare(seqNo, startIndex[:]) > 0; seqNo, indexValue = invoiceCursor.Next() {
|
for ; seqNo != nil && bytes.Compare(seqNo, startIndex[:]) > 0; seqNo, indexValue = invoiceCursor.Next() {
|
||||||
|
|
||||||
// Depending on the length of the index value, this may
|
// Depending on the length of the index value, this may
|
||||||
// or may not be an AMP invoice, so we'll extract the
|
// or may not be an AMP invoice, so we'll extract the
|
||||||
// invoice value into two components: the invoice num,
|
// invoice value into two components: the invoice num,
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ func MigrateFwdPkgCleanup(tx kvdb.RwTx) error {
|
|||||||
|
|
||||||
// Otherwise, wipe all the forwarding packages.
|
// Otherwise, wipe all the forwarding packages.
|
||||||
if err := fwdPkgBkt.DeleteNestedBucket(
|
if err := fwdPkgBkt.DeleteNestedBucket(
|
||||||
sourceBytes[:]); err != nil {
|
sourceBytes[:],
|
||||||
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -615,9 +615,8 @@ func TestFetchPaymentWithSequenceNumber(t *testing.T) {
|
|||||||
test := test
|
test := test
|
||||||
|
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
err := kvdb.Update(db,
|
err := kvdb.Update(
|
||||||
func(tx walletdb.ReadWriteTx) error {
|
db, func(tx walletdb.ReadWriteTx) error {
|
||||||
|
|
||||||
var seqNrBytes [8]byte
|
var seqNrBytes [8]byte
|
||||||
byteOrder.PutUint64(
|
byteOrder.PutUint64(
|
||||||
seqNrBytes[:], test.sequenceNumber,
|
seqNrBytes[:], test.sequenceNumber,
|
||||||
@@ -627,7 +626,8 @@ func TestFetchPaymentWithSequenceNumber(t *testing.T) {
|
|||||||
tx, test.paymentHash, seqNrBytes[:],
|
tx, test.paymentHash, seqNrBytes[:],
|
||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
}, func() {})
|
}, func() {},
|
||||||
|
)
|
||||||
require.Equal(t, test.expectedErr, err)
|
require.Equal(t, test.expectedErr, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ func newTestBoltArbLog(chainhash chainhash.Hash,
|
|||||||
testArbCfg := ChannelArbitratorConfig{
|
testArbCfg := ChannelArbitratorConfig{
|
||||||
PutResolverReport: func(_ kvdb.RwTx,
|
PutResolverReport: func(_ kvdb.RwTx,
|
||||||
_ *channeldb.ResolverReport) error {
|
_ *channeldb.ResolverReport) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,6 +383,7 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog,
|
|||||||
},
|
},
|
||||||
MarkChannelClosed: func(*channeldb.ChannelCloseSummary,
|
MarkChannelClosed: func(*channeldb.ChannelCloseSummary,
|
||||||
...channeldb.ChannelStatus) error {
|
...channeldb.ChannelStatus) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
IsPendingClose: false,
|
IsPendingClose: false,
|
||||||
@@ -1635,6 +1636,7 @@ func TestChannelArbitratorCommitFailure(t *testing.T) {
|
|||||||
chanArb.cfg.MarkChannelClosed = func(
|
chanArb.cfg.MarkChannelClosed = func(
|
||||||
*channeldb.ChannelCloseSummary,
|
*channeldb.ChannelCloseSummary,
|
||||||
...channeldb.ChannelStatus) error {
|
...channeldb.ChannelStatus) error {
|
||||||
|
|
||||||
close(closed)
|
close(closed)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -2169,6 +2171,7 @@ func TestRemoteCloseInitiator(t *testing.T) {
|
|||||||
// about setting of channel status.
|
// about setting of channel status.
|
||||||
mockMarkClosed := func(_ *channeldb.ChannelCloseSummary,
|
mockMarkClosed := func(_ *channeldb.ChannelCloseSummary,
|
||||||
statuses ...channeldb.ChannelStatus) error {
|
statuses ...channeldb.ChannelStatus) error {
|
||||||
|
|
||||||
for _, status := range statuses {
|
for _, status := range statuses {
|
||||||
err := alice.State().ApplyChanStatus(status)
|
err := alice.State().ApplyChanStatus(status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ func newHtlcResolverTestContext(t *testing.T,
|
|||||||
Sweeper: newMockSweeper(),
|
Sweeper: newMockSweeper(),
|
||||||
IncubateOutputs: func(wire.OutPoint, *lnwallet.OutgoingHtlcResolution,
|
IncubateOutputs: func(wire.OutPoint, *lnwallet.OutgoingHtlcResolution,
|
||||||
*lnwallet.IncomingHtlcResolution, uint32) error {
|
*lnwallet.IncomingHtlcResolution, uint32) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
DeliverResolutionMsg: func(msgs ...ResolutionMsg) error {
|
DeliverResolutionMsg: func(msgs ...ResolutionMsg) error {
|
||||||
@@ -86,6 +87,7 @@ func newHtlcResolverTestContext(t *testing.T,
|
|||||||
// this so set nolint directive.
|
// this so set nolint directive.
|
||||||
checkpointFunc := func(c ContractResolver, // nolint
|
checkpointFunc := func(c ContractResolver, // nolint
|
||||||
r ...*channeldb.ResolverReport) error {
|
r ...*channeldb.ResolverReport) error {
|
||||||
|
|
||||||
return testCtx.checkpoint(c, r...)
|
return testCtx.checkpoint(c, r...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,6 +255,7 @@ func TestHtlcSuccessSecondStageResolution(t *testing.T) {
|
|||||||
// to resolve our htlc.
|
// to resolve our htlc.
|
||||||
preCheckpoint: func(ctx *htlcResolverTestContext,
|
preCheckpoint: func(ctx *htlcResolverTestContext,
|
||||||
_ bool) error {
|
_ bool) error {
|
||||||
|
|
||||||
ctx.notifier.SpendChan <- &chainntnfs.SpendDetail{
|
ctx.notifier.SpendChan <- &chainntnfs.SpendDetail{
|
||||||
SpendingTx: sweepTx,
|
SpendingTx: sweepTx,
|
||||||
SpenderTxHash: &sweepHash,
|
SpenderTxHash: &sweepHash,
|
||||||
|
|||||||
@@ -861,6 +861,7 @@ func TestHtlcTimeoutSecondStageRemoteSpend(t *testing.T) {
|
|||||||
// success transcation.
|
// success transcation.
|
||||||
preCheckpoint: func(ctx *htlcResolverTestContext,
|
preCheckpoint: func(ctx *htlcResolverTestContext,
|
||||||
_ bool) error {
|
_ bool) error {
|
||||||
|
|
||||||
ctx.notifier.SpendChan <- &chainntnfs.SpendDetail{
|
ctx.notifier.SpendChan <- &chainntnfs.SpendDetail{
|
||||||
SpendingTx: remoteSuccessTx,
|
SpendingTx: remoteSuccessTx,
|
||||||
SpenderTxHash: &successTxid,
|
SpenderTxHash: &successTxid,
|
||||||
|
|||||||
@@ -100,9 +100,14 @@
|
|||||||
|
|
||||||
* [The `golangci-lint` package was updated and new linters were
|
* [The `golangci-lint` package was updated and new linters were
|
||||||
enabled](https://github.com/lightningnetwork/lnd/pull/6244).
|
enabled](https://github.com/lightningnetwork/lnd/pull/6244).
|
||||||
**Note to developers**: please make sure you delete the old version of
|
|
||||||
`golangci-lint` in your `$GOPATH/bin` directory. `make lint` does not
|
* The linting process now runs [inside a docker
|
||||||
automatically replace it with the new version if the binary already exists!
|
container](https://github.com/lightningnetwork/lnd/pull/6248) to fix
|
||||||
|
versioning issues between projects.
|
||||||
|
|
||||||
|
* The [`whitespace` linter](https://github.com/lightningnetwork/lnd/pull/6270)
|
||||||
|
was enabled to make sure multi-line `if` conditions and function/method
|
||||||
|
declarations are followed by an empty line to improve readability.
|
||||||
|
|
||||||
# Contributors (Alphabetical Order)
|
# Contributors (Alphabetical Order)
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ func newMailboxContext(t *testing.T, startTime time.Time,
|
|||||||
ctx.mailbox = newMemoryMailBox(&mailBoxConfig{
|
ctx.mailbox = newMemoryMailBox(&mailBoxConfig{
|
||||||
fetchUpdate: func(sid lnwire.ShortChannelID) (
|
fetchUpdate: func(sid lnwire.ShortChannelID) (
|
||||||
*lnwire.ChannelUpdate, error) {
|
*lnwire.ChannelUpdate, error) {
|
||||||
|
|
||||||
return &lnwire.ChannelUpdate{
|
return &lnwire.ChannelUpdate{
|
||||||
ShortChannelID: sid,
|
ShortChannelID: sid,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -671,12 +672,14 @@ func TestMailOrchestrator(t *testing.T) {
|
|||||||
mo := newMailOrchestrator(&mailOrchConfig{
|
mo := newMailOrchestrator(&mailOrchConfig{
|
||||||
fetchUpdate: func(sid lnwire.ShortChannelID) (
|
fetchUpdate: func(sid lnwire.ShortChannelID) (
|
||||||
*lnwire.ChannelUpdate, error) {
|
*lnwire.ChannelUpdate, error) {
|
||||||
|
|
||||||
return &lnwire.ChannelUpdate{
|
return &lnwire.ChannelUpdate{
|
||||||
ShortChannelID: sid,
|
ShortChannelID: sid,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
forwardPackets: func(_ chan struct{},
|
forwardPackets: func(_ chan struct{},
|
||||||
pkts ...*htlcPacket) error {
|
pkts ...*htlcPacket) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
clock: clock.NewTestClock(time.Now()),
|
clock: clock.NewTestClock(time.Now()),
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ func lockInputs(w lnwallet.WalletController, packet *psbt.Packet) (
|
|||||||
if err := w.ReleaseOutput(
|
if err := w.ReleaseOutput(
|
||||||
LndInternalLockID, op,
|
LndInternalLockID, op,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
|
||||||
log.Errorf("could not release the "+
|
log.Errorf("could not release the "+
|
||||||
"lock on %v: %v", op, err)
|
"lock on %v: %v", op, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// response to a channel balance RPC.
|
// response to a channel balance RPC.
|
||||||
checkChannelBalance := func(node *lntest.HarnessNode,
|
checkChannelBalance := func(node *lntest.HarnessNode,
|
||||||
local, remote, pendingLocal, pendingRemote btcutil.Amount) {
|
local, remote, pendingLocal, pendingRemote btcutil.Amount) {
|
||||||
|
|
||||||
expectedResponse := &lnrpc.ChannelBalanceResponse{
|
expectedResponse := &lnrpc.ChannelBalanceResponse{
|
||||||
LocalBalance: &lnrpc.Amount{
|
LocalBalance: &lnrpc.Amount{
|
||||||
Sat: uint64(local),
|
Sat: uint64(local),
|
||||||
|
|||||||
@@ -614,8 +614,8 @@ func createTestGraphFromChannels(useCache bool, testChannels []*testChannel,
|
|||||||
|
|
||||||
for _, testChannel := range testChannels {
|
for _, testChannel := range testChannels {
|
||||||
for _, node := range []*testChannelEnd{
|
for _, node := range []*testChannelEnd{
|
||||||
testChannel.Node1, testChannel.Node2} {
|
testChannel.Node1, testChannel.Node2,
|
||||||
|
} {
|
||||||
_, exists := aliasMap[node.Alias]
|
_, exists := aliasMap[node.Alias]
|
||||||
if !exists {
|
if !exists {
|
||||||
var features *lnwire.FeatureVector
|
var features *lnwire.FeatureVector
|
||||||
|
|||||||
@@ -779,7 +779,6 @@ func (p *shardHandler) handleSendError(attempt *channeldb.HTLCAttemptInfo,
|
|||||||
if err := p.router.cfg.Control.Fail(
|
if err := p.router.cfg.Control.Fail(
|
||||||
p.identifier, *reason,
|
p.identifier, *reason,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
|
||||||
log.Errorf("unable to report failure to control "+
|
log.Errorf("unable to report failure to control "+
|
||||||
"tower: %v", err)
|
"tower: %v", err)
|
||||||
|
|
||||||
|
|||||||
@@ -670,7 +670,6 @@ func TestSendPaymentErrorFeeInsufficientPrivateEdge(t *testing.T) {
|
|||||||
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop != roasbeefSongoku || errorReturned {
|
if firstHop != roasbeefSongoku || errorReturned {
|
||||||
return preImage, nil
|
return preImage, nil
|
||||||
}
|
}
|
||||||
@@ -685,7 +684,8 @@ func TestSendPaymentErrorFeeInsufficientPrivateEdge(t *testing.T) {
|
|||||||
Update: errChanUpdate,
|
Update: errChanUpdate,
|
||||||
}, 1,
|
}, 1,
|
||||||
)
|
)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// Send off the payment request to the router, route through son
|
// Send off the payment request to the router, route through son
|
||||||
// goku and then across the private channel to elst.
|
// goku and then across the private channel to elst.
|
||||||
@@ -802,7 +802,6 @@ func TestSendPaymentPrivateEdgeUpdateFeeExceedsLimit(t *testing.T) {
|
|||||||
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
if firstHop != roasbeefSongoku || errorReturned {
|
if firstHop != roasbeefSongoku || errorReturned {
|
||||||
return preImage, nil
|
return preImage, nil
|
||||||
}
|
}
|
||||||
@@ -817,7 +816,8 @@ func TestSendPaymentPrivateEdgeUpdateFeeExceedsLimit(t *testing.T) {
|
|||||||
Update: errChanUpdate,
|
Update: errChanUpdate,
|
||||||
}, 1,
|
}, 1,
|
||||||
)
|
)
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// Send off the payment request to the router, route through son
|
// Send off the payment request to the router, route through son
|
||||||
// goku and then across the private channel to elst.
|
// goku and then across the private channel to elst.
|
||||||
@@ -3071,7 +3071,6 @@ func TestSendToRouteMultiShardSend(t *testing.T) {
|
|||||||
|
|
||||||
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
ctx.router.cfg.Payer.(*mockPaymentAttemptDispatcherOld).setPaymentResult(
|
||||||
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
func(firstHop lnwire.ShortChannelID) ([32]byte, error) {
|
||||||
|
|
||||||
// Signal that the shard has been initiated and is
|
// Signal that the shard has been initiated and is
|
||||||
// waiting for a result.
|
// waiting for a result.
|
||||||
waitForResultSignal <- struct{}{}
|
waitForResultSignal <- struct{}{}
|
||||||
@@ -3082,7 +3081,8 @@ func TestSendToRouteMultiShardSend(t *testing.T) {
|
|||||||
return [32]byte{}, fmt.Errorf("failure")
|
return [32]byte{}, fmt.Errorf("failure")
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// Launch three shards by calling SendToRoute in three goroutines,
|
// Launch three shards by calling SendToRoute in three goroutines,
|
||||||
// returning their final error on the channel.
|
// returning their final error on the channel.
|
||||||
|
|||||||
@@ -1653,7 +1653,6 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
|
|||||||
if err := r.server.ConnectToPeer(
|
if err := r.server.ConnectToPeer(
|
||||||
peerAddr, in.Perm, timeout,
|
peerAddr, in.Perm, timeout,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
|
||||||
rpcsLog.Errorf(
|
rpcsLog.Errorf(
|
||||||
"[connectpeer]: error connecting to peer: %v", err,
|
"[connectpeer]: error connecting to peer: %v", err,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,3 +11,6 @@ require (
|
|||||||
github.com/rinchsan/gosimports v0.1.5
|
github.com/rinchsan/gosimports v0.1.5
|
||||||
github.com/stephens2424/writerset v1.0.2 // indirect
|
github.com/stephens2424/writerset v1.0.2 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Can be removed once this version is included in golangci-lint.
|
||||||
|
replace github.com/ultraware/whitespace => github.com/ultraware/whitespace v0.0.5
|
||||||
+2
-2
@@ -859,8 +859,8 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr
|
|||||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iLA=
|
github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iLA=
|
||||||
github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
|
||||||
github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFODYDsg=
|
github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI=
|
||||||
github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
|
github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
github.com/uudashr/gocognit v1.0.5 h1:rrSex7oHr3/pPLQ0xoWq108XMU8s678FJcQ+aSfOHa4=
|
github.com/uudashr/gocognit v1.0.5 h1:rrSex7oHr3/pPLQ0xoWq108XMU8s678FJcQ+aSfOHa4=
|
||||||
|
|||||||
Reference in new issue
Block a user