diff --git a/.golangci.yml b/.golangci.yml index fed729c41..9b3302460 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -58,6 +58,9 @@ linters: # Init functions are used by loggers throughout the codebase. - gochecknoinits + # interfacer has been archived. + - interfacer + issues: # Only show newly introduced problems. new-from-rev: 01f696afce2f9c0d4ed854edefa3846891d01d8a diff --git a/channeldb/channel.go b/channeldb/channel.go index 00d95fe2a..9084d973d 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -882,8 +882,9 @@ func fetchChanBucket(tx kvdb.RTx, nodeKey *btcec.PublicKey, // channel's data resides in given: the public key for the node, the outpoint, // and the chainhash that the channel resides on. This differs from // fetchChanBucket in that it returns a writeable bucket. -func fetchChanBucketRw(tx kvdb.RwTx, nodeKey *btcec.PublicKey, // nolint:interfacer - outPoint *wire.OutPoint, chainHash chainhash.Hash) (kvdb.RwBucket, error) { +func fetchChanBucketRw(tx kvdb.RwTx, nodeKey *btcec.PublicKey, + outPoint *wire.OutPoint, chainHash chainhash.Hash) (kvdb.RwBucket, + error) { // First fetch the top level bucket which stores all data related to // current, active channels. diff --git a/channeldb/graph.go b/channeldb/graph.go index 7452bea8f..e4f0f9b94 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -578,7 +578,9 @@ func (c *ChannelGraph) DisabledChannelIDs() ([]uint64, error) { // // TODO(roasbeef): add iterator interface to allow for memory efficient graph // traversal when graph gets mega -func (c *ChannelGraph) ForEachNode(cb func(kvdb.RTx, *LightningNode) error) error { // nolint:interfacer +func (c *ChannelGraph) ForEachNode( + cb func(kvdb.RTx, *LightningNode) error) error { + traversal := func(tx kvdb.RTx) error { // First grab the nodes bucket which stores the mapping from // pubKey to node information. diff --git a/channeldb/payments.go b/channeldb/payments.go index 6450025a4..fefdf5bfd 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -731,7 +731,9 @@ func fetchPaymentWithSequenceNumber(tx kvdb.RTx, paymentHash lntypes.Hash, // DeletePayment deletes a payment from the DB given its payment hash. If // failedHtlcsOnly is set, only failed HTLC attempts of the payment will be // deleted. -func (d *DB) DeletePayment(paymentHash lntypes.Hash, failedHtlcsOnly bool) error { // nolint:interfacer +func (d *DB) DeletePayment(paymentHash lntypes.Hash, + failedHtlcsOnly bool) error { + return kvdb.Update(d, func(tx kvdb.RwTx) error { payments := tx.ReadWriteBucket(paymentsRootBucket) if payments == nil { diff --git a/lntest/harness_net.go b/lntest/harness_net.go index 72e34122d..c4c7b2a87 100644 --- a/lntest/harness_net.go +++ b/lntest/harness_net.go @@ -1351,7 +1351,6 @@ func (n *NetworkHarness) WaitForChannelClose( // an optional set of check functions which can be used to make further // assertions using channel's values. These functions are responsible for // failing the test themselves if they do not pass. -// nolint: interfacer func (n *NetworkHarness) AssertChannelExists(node *HarnessNode, chanPoint *wire.OutPoint, checks ...func(*lnrpc.Channel)) error { diff --git a/lntest/itest/assertions.go b/lntest/itest/assertions.go index 6304b92c1..54fc1270c 100644 --- a/lntest/itest/assertions.go +++ b/lntest/itest/assertions.go @@ -589,9 +589,8 @@ func shutdownAndAssert(net *lntest.NetworkHarness, t *harnessTest, // assertChannelBalanceResp makes a ChannelBalance request and checks the // returned response matches the expected. -func assertChannelBalanceResp(t *harnessTest, - node *lntest.HarnessNode, - expected *lnrpc.ChannelBalanceResponse) { // nolint:interfacer +func assertChannelBalanceResp(t *harnessTest, node *lntest.HarnessNode, + expected *lnrpc.ChannelBalanceResponse) { resp := getChannelBalance(t, node) require.True(t.t, proto.Equal(expected, resp), "balance is incorrect") diff --git a/lnwire/writer.go b/lnwire/writer.go index 0b08c951d..2ed87cded 100644 --- a/lnwire/writer.go +++ b/lnwire/writer.go @@ -50,32 +50,20 @@ func ErrOutpointIndexTooBig(index uint32) error { } // WriteBytes appends the given bytes to the provided buffer. -// -// Note: We intentionally skip the interfacer linter check here because we want -// to have concrete type (bytes.Buffer) rather than interface type (io.Write) -// due to performance concern. -func WriteBytes(buf *bytes.Buffer, b []byte) error { // nolint: interfacer +func WriteBytes(buf *bytes.Buffer, b []byte) error { _, err := buf.Write(b) return err } // WriteUint8 appends the uint8 to the provided buffer. -// -// Note: We intentionally skip the interfacer linter check here because we want -// to have concrete type (bytes.Buffer) rather than interface type (io.Write) -// due to performance concern. -func WriteUint8(buf *bytes.Buffer, n uint8) error { // nolint: interfacer +func WriteUint8(buf *bytes.Buffer, n uint8) error { _, err := buf.Write([]byte{n}) return err } // WriteUint16 appends the uint16 to the provided buffer. It encodes the // integer using big endian byte order. -// -// Note: We intentionally skip the interfacer linter check here because we want -// to have concrete type (bytes.Buffer) rather than interface type (io.Write) -// due to performance concern. -func WriteUint16(buf *bytes.Buffer, n uint16) error { // nolint: interfacer +func WriteUint16(buf *bytes.Buffer, n uint16) error { var b [2]byte binary.BigEndian.PutUint16(b[:], n) _, err := buf.Write(b[:]) @@ -93,11 +81,7 @@ func WriteUint32(buf *bytes.Buffer, n uint32) error { // WriteUint64 appends the uint64 to the provided buffer. It encodes the // integer using big endian byte order. -// -// Note: We intentionally skip the interfacer linter check here because we want -// to have concrete type (bytes.Buffer) rather than interface type (io.Write) -// due to performance concern. -func WriteUint64(buf *bytes.Buffer, n uint64) error { // nolint: interfacer +func WriteUint64(buf *bytes.Buffer, n uint64) error { var b [8]byte binary.BigEndian.PutUint64(b[:], n) _, err := buf.Write(b[:]) @@ -194,13 +178,7 @@ func WriteFailCode(buf *bytes.Buffer, e FailCode) error { // WriteRawFeatureVector encodes the feature using the feature's Encode method // and appends the data to the provided buffer. An error will return if the // passed feature is nil. -// -// Note: We intentionally skip the interfacer linter check here because we want -// to have concrete type (bytes.Buffer) rather than interface type (io.Write) -// due to performance concern. -func WriteRawFeatureVector(buf *bytes.Buffer, // nolint: interfacer - feature *RawFeatureVector) error { - +func WriteRawFeatureVector(buf *bytes.Buffer, feature *RawFeatureVector) error { if feature == nil { return ErrNilFeatureVector } @@ -280,11 +258,7 @@ func WriteBool(buf *bytes.Buffer, b bool) error { // WritePkScript appends the script to the provided buffer. Returns an error if // the provided script exceeds 34 bytes. -// -// Note: We intentionally skip the interfacer linter check here because we want -// to have concrete type (bytes.Buffer) rather than interface type (io.Write) -// due to performance concern. -func WritePkScript(buf *bytes.Buffer, s PkScript) error { // nolint: interfacer +func WritePkScript(buf *bytes.Buffer, s PkScript) error { // The largest script we'll accept is a p2wsh which is exactly // 34 bytes long. scriptLength := len(s) @@ -412,13 +386,7 @@ func WriteNetAddrs(buf *bytes.Buffer, addresses []net.Addr) error { } // writeDataWithLength writes the data and its length to the buffer. -// -// Note: We intentionally skip the interfacer linter check here because we want -// to have concrete type (bytes.Buffer) rather than interface type (io.Write) -// due to performance concern. -func writeDataWithLength(buf *bytes.Buffer, // nolint: interfacer - data []byte) error { - +func writeDataWithLength(buf *bytes.Buffer, data []byte) error { var l [2]byte binary.BigEndian.PutUint16(l[:], uint16(len(data))) if _, err := buf.Write(l[:]); err != nil {