Skip to content

Commit b1b75c8

Browse files
authored
Merge pull request #1189 from lightninglabs/lint-line-length
multi: enforce 80-char line length and add `nolint:ll` comments
2 parents 6e6b552 + a0e6312 commit b1b75c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+857
-219
lines changed

.custom-gcl.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: v1.64.6
2+
plugins:
3+
- module: 'github.com/lightninglabs/lightning-terminal/tools/linters'
4+
path: ./tools/linters

.golangci.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ run:
1414
- dev
1515

1616
linters-settings:
17+
custom:
18+
ll:
19+
type: "module"
20+
description: "Custom lll linter with 'S' log line exclusion."
21+
settings:
22+
# Max line length, lines longer will be reported.
23+
line-length: 80
24+
# Tab width in spaces.
25+
tab-width: 8
26+
# The regex that we will use to detect the start of an `S` log line.
27+
log-regex: "^\\s*.*(L|l)og\\.(Info|Debug|Trace|Warn|Error|Critical)S\\("
1728
govet:
1829
# Don't report about shadowed variables
1930
check-shadowing: false
@@ -39,7 +50,7 @@ linters-settings:
3950

4051
linters:
4152
enable:
42-
- lll
53+
- ll
4354
- gofmt
4455
- tagliatelle
4556
- whitespace

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ check-go-version: check-go-version-dockerfile check-go-version-yaml
304304

305305
lint: check-go-version docker-tools
306306
@$(call print, "Linting source.")
307-
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
307+
$(DOCKER_TOOLS) custom-gcl run -v $(LINT_WORKERS)
308308

309309
mod:
310310
@$(call print, "Tidying modules.")

accounts/checkers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func NewAccountChecker(service Service,
110110
)
111111
}
112112

113+
// nolint:ll
113114
checkers := CheckerMap{
114115
// Invoices:
115116
"/lnrpc.Lightning/AddInvoice": mid.NewResponseRewriter(

accounts/checkers_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ func TestAccountCheckers(t *testing.T) {
379379
originalRequest: &lnrpc.PendingChannelsRequest{},
380380
originalResponse: &lnrpc.PendingChannelsResponse{
381381
TotalLimboBalance: 123456,
382+
// nolint:ll
382383
PendingOpenChannels: []*lnrpc.PendingChannelsResponse_PendingOpenChannel{
383384
{},
384385
},

accounts/store_sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131
// SQLQueries is a subset of the sqlc.Queries interface that can be used
3232
// to interact with accounts related tables.
3333
//
34-
//nolint:lll
34+
//nolint:ll
3535
type SQLQueries interface {
3636
AddAccountInvoice(ctx context.Context, arg sqlc.AddAccountInvoiceParams) error
3737
DeleteAccount(ctx context.Context, id int64) error

accounts/tlv.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ func PaymentEntryMapEncoder(w io.Writer, val any, buf *[8]byte) error {
227227
}
228228

229229
// PaymentEntryMapDecoder decodes a map of payment entries.
230-
func PaymentEntryMapDecoder(r io.Reader, val any, buf *[8]byte, _ uint64) error {
230+
func PaymentEntryMapDecoder(r io.Reader, val any, buf *[8]byte,
231+
_ uint64) error {
232+
231233
if typ, ok := val.(*AccountPayments); ok {
232234
numItems, err := tlv.ReadVarInt(r, buf)
233235
if err != nil {

autopilotserver/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var ErrVersionIncompatible = fmt.Errorf("litd version is not compatible " +
2727

2828
// Config holds the configuration options for the autopilot server client.
2929
//
30-
//nolint:lll
30+
//nolint:ll
3131
type Config struct {
3232
// Disable will disable the autopilot client.
3333
Disable bool `long:"disable" description:"disable the autopilot client"`

autopilotserver/mock/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ func (m *Server) GetPrivacyFlags(remoteKey *btcec.PublicKey) (
310310
key := hex.EncodeToString(remoteKey.SerializeCompressed())
311311
sess, ok := m.sessions[key]
312312
if !ok {
313-
return session.PrivacyFlags{}, fmt.Errorf("no such client found")
313+
return session.PrivacyFlags{},
314+
fmt.Errorf("no such client found")
314315
}
315316

316317
privacyFlags, err := session.Deserialize(sess.privacyFlags)
@@ -436,7 +437,9 @@ func rulesToRPC(rulesMap map[string]*RuleRanges) (
436437
return res, nil
437438
}
438439

439-
func permissionsToRPC(ps map[string][]bakery.Op) []*autopilotserverrpc.Permissions {
440+
func permissionsToRPC(
441+
ps map[string][]bakery.Op) []*autopilotserverrpc.Permissions {
442+
440443
res := make([]*autopilotserverrpc.Permissions, len(ps))
441444

442445
for method, ops := range ps {

cmd/litcli/accounts.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ var updateAccountCommand = cli.Command{
146146
Name: "update",
147147
ShortName: "u",
148148
Usage: "Update an existing off-chain account.",
149-
ArgsUsage: "[id | label] new_balance [new_expiration_date] [--save_to=]",
149+
ArgsUsage: "[id | label] new_balance [new_expiration_date] " +
150+
"[--save_to=]",
150151
Description: "Updates an existing off-chain account and sets " +
151152
"either a new balance or new expiration date or both.",
152153
Flags: []cli.Flag{

0 commit comments

Comments
 (0)