diff --git a/.golangci.yml b/.golangci.yml index 272376a..d3da6bf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -67,6 +67,12 @@ linters: - golint - maligned - scopelint + - varcheck + - structcheck + - deadcode + + # gRPC needs snake case notation. + - nosnakecase # New linters that need a code adjustment first. - wrapcheck @@ -103,6 +109,7 @@ linters: - revive - promlinter - forbidigo + - interfacebloat issues: exclude-rules: diff --git a/account/manager_test.go b/account/manager_test.go index 6905146..045752b 100644 --- a/account/manager_test.go +++ b/account/manager_test.go @@ -223,7 +223,7 @@ func (h *testHarness) expireAccount(account *Account) { } func (h *testHarness) closeAccount(account *Account, feeExpr FeeExpr, - bestHeight uint32) *wire.MsgTx { + bestHeight uint32) { h.t.Helper() @@ -259,8 +259,6 @@ func (h *testHarness) closeAccount(account *Account, feeExpr FeeExpr, account.State = StateClosed account.HeightHint = spendHeight h.assertAccountExists(account) - - return closeTx } func (h *testHarness) assertSpendTxBroadcast(accountBeforeSpend *Account, @@ -1058,7 +1056,7 @@ func TestAccountWithdrawal(t *testing.T) { // Finally, close the account to ensure we can process another // spend after the withdrawal. expr := defaultFeeExpr - _ = h.closeAccount(account, &expr, bestHeight) + h.closeAccount(account, &expr, bestHeight) }) } @@ -1233,7 +1231,7 @@ func TestAccountDeposit(t *testing.T) { // Finally, close the account to ensure we can process another // spend after the withdrawal. expr := defaultFeeExpr - _ = h.closeAccount(account, &expr, bestHeight) + h.closeAccount(account, &expr, bestHeight) }) } diff --git a/backoff.go b/backoff.go index 9455618..6db368e 100644 --- a/backoff.go +++ b/backoff.go @@ -3,7 +3,7 @@ package pool import "time" const ( - // maxBackOff is the maximum amount of that that we'll wait to retry to + // maxBackOff is the maximum amount of that we'll wait to retry to // w/e operation we're wanting to back off. maxBackOff = time.Minute diff --git a/cmd/pool/order.go b/cmd/pool/order.go index 7a30a25..62874ad 100644 --- a/cmd/pool/order.go +++ b/cmd/pool/order.go @@ -269,7 +269,7 @@ func getMinChanAmount(ctx *cli.Context, orderAmt uint64, return 0 } -// validateMinChanAmount checks that the the minimum channel amount parameter +// validateMinChanAmount checks that the minimum channel amount parameter // has been properly set. func validateMinChanAmount(ctx *cli.Context, orderAmt, minChanAmt btcutil.Amount, orderType order.Type) error { diff --git a/order/interfaces.go b/order/interfaces.go index c56c627..2036952 100644 --- a/order/interfaces.go +++ b/order/interfaces.go @@ -429,7 +429,7 @@ type Kit struct { // has been formally validated. MultiSigKeyLocator keychain.KeyLocator - // MaxBatchFeeRate is is the maximum fee rate the trader is willing to + // MaxBatchFeeRate is the maximum fee rate the trader is willing to // pay for the batch transaction, in sat/kW. MaxBatchFeeRate chainfee.SatPerKWeight diff --git a/order/rpc_parse.go b/order/rpc_parse.go index d36bd5b..abe1a38 100644 --- a/order/rpc_parse.go +++ b/order/rpc_parse.go @@ -102,7 +102,7 @@ func ParseRPCOrder(version, leaseDuration uint32, // Default value, trader didn't specify a channel type. case auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_UNKNOWN: // If we have a chan type selector, we'll use that, otherwise - // we'll just use peer dependent channels as as default. + // we'll just use peer dependent channels as default. if opts.chanTypeSelector != nil { kit.ChannelType = opts.chanTypeSelector() } else { diff --git a/rpcserver.go b/rpcserver.go index 146f02a..a14b319 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -3024,7 +3024,7 @@ func (s *rpcServer) setTicketStateForOrder(newState sidecar.State, // determineAccountVersion parses the RPC version and makes sure it can actually // be used. func (s *rpcServer) determineAccountVersion( - newVersion poolrpc.AccountVersion) (account.Version, error) { + newVersion poolrpc.AccountVersion) (account.Version, error) { //nolint // Now we can do the account version validation. switch newVersion { diff --git a/rpcserver_test.go b/rpcserver_test.go index 3dd9ca9..d2efcdf 100644 --- a/rpcserver_test.go +++ b/rpcserver_test.go @@ -30,7 +30,7 @@ func getAccountKey(acctKey []byte) *btcec.PublicKey { return res } -func genRenewAccountReq(accountKey []byte, absolute, relative uint32, +func genRenewAccountReq(accountKey []byte, relative uint32, feerate uint64, version uint32) *poolrpc.RenewAccountRequest { req := &poolrpc.RenewAccountRequest{ @@ -41,14 +41,8 @@ func genRenewAccountReq(accountKey []byte, absolute, relative uint32, req.AccountKey = accountKey req.FeeRateSatPerKw = feerate - if absolute != 0 { - req.AccountExpiry = &poolrpc.RenewAccountRequest_AbsoluteExpiry{ - AbsoluteExpiry: absolute, - } - } else { - req.AccountExpiry = &poolrpc.RenewAccountRequest_RelativeExpiry{ - RelativeExpiry: relative, - } + req.AccountExpiry = &poolrpc.RenewAccountRequest_RelativeExpiry{ + RelativeExpiry: relative, } return req @@ -70,7 +64,7 @@ var renewAccountTestCases = []struct { AppPatch: 3, }, getReq: func() *poolrpc.RenewAccountRequest { - return genRenewAccountReq(traderKeyRaw, 0, 10, 1000, 1) + return genRenewAccountReq(traderKeyRaw, 10, 1000, 1) }, mockSetter: func(req *poolrpc.RenewAccountRequest, accMgr *account.MockManager, marshalerMock *MockMarshaler) { @@ -105,7 +99,7 @@ var renewAccountTestCases = []struct { name: "we are able to successfully renew an account", lndVer: minimalCompatibleVersion, getReq: func() *poolrpc.RenewAccountRequest { - return genRenewAccountReq(traderKeyRaw, 0, 10, 1000, 0) + return genRenewAccountReq(traderKeyRaw, 10, 1000, 0) }, mockSetter: func(req *poolrpc.RenewAccountRequest, accMgr *account.MockManager, marshalerMock *MockMarshaler) { @@ -155,7 +149,7 @@ var renewAccountTestCases = []struct { name: "req should specify absolute/relative expiry", lndVer: minimalCompatibleVersion, getReq: func() *poolrpc.RenewAccountRequest { - return genRenewAccountReq(traderKeyRaw, 0, 0, 1000, 0) + return genRenewAccountReq(traderKeyRaw, 0, 1000, 0) }, expectedError: "either relative or absolute height must be specified", mockSetter: func(req *poolrpc.RenewAccountRequest, @@ -168,7 +162,7 @@ var renewAccountTestCases = []struct { name: "req should specify a valid fee rate", lndVer: minimalCompatibleVersion, getReq: func() *poolrpc.RenewAccountRequest { - return genRenewAccountReq(traderKeyRaw, 0, 100, 0, 0) + return genRenewAccountReq(traderKeyRaw, 100, 0, 0) }, expectedError: "fee rate of 0 sat/kw is too low, minimum is 253 sat/kw", mockSetter: func(req *poolrpc.RenewAccountRequest, diff --git a/run.go b/run.go index 36b46a9..edfa560 100644 --- a/run.go +++ b/run.go @@ -50,6 +50,7 @@ func Run(cfg *Config) error { "/debug/pprof", http.StatusSeeOther, ) http.Handle("/", profileRedirect) + //nolint:gosec fmt.Println(http.ListenAndServe(cfg.Profile, nil)) }() } diff --git a/server.go b/server.go index 9312ea6..39f5914 100644 --- a/server.go +++ b/server.go @@ -287,7 +287,7 @@ func (s *Server) Start() error { s.restListener = tls.NewListener(s.restListener, serverTLSCfg) shutdownFuncs["restListener"] = s.restListener.Close - s.restProxy = &http.Server{Handler: mux} + s.restProxy = &http.Server{Handler: mux} //nolint:gosec s.wg.Add(1) go func() { defer s.wg.Done()