Skip to content

Commit b81f0d7

Browse files
authored
chore: use gofumpt (#196)
## Overview Unify formatting with `celestia-node` and other Celestia projects in the future.
1 parent 72d6506 commit b81f0d7

File tree

7 files changed

+93
-15
lines changed

7 files changed

+93
-15
lines changed

.golangci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
run:
2+
timeout: 5m
3+
4+
linters:
5+
enable:
6+
- bidichk
7+
- bodyclose
8+
# - depguard as of v1.54.2, the default config throws errors on our repo
9+
- dogsled
10+
- dupl
11+
- errcheck
12+
- errorlint
13+
# - funlen
14+
# - gochecknoglobals
15+
# - gochecknoinits
16+
- exportloopref
17+
- gocheckcompilerdirectives
18+
- goconst
19+
- gocritic
20+
# - gocyclo
21+
# - godox
22+
- gofmt
23+
- gofumpt
24+
- goimports
25+
# - golint - deprecated since v1.41. revive will be used instead
26+
- revive
27+
- gosec
28+
- gosimple
29+
- govet
30+
- ineffassign
31+
# - interfacer
32+
- lll
33+
- loggercheck
34+
- misspell
35+
# - maligned
36+
- nakedret
37+
- nilerr
38+
- nilnil
39+
- nolintlint
40+
- prealloc
41+
- protogetter
42+
# - scopelint - deprecated since v1.39. exportloopref will be used instead
43+
- exportloopref
44+
- staticcheck
45+
- stylecheck
46+
- typecheck
47+
- unconvert
48+
# - unparam
49+
- unused
50+
# - whitespace
51+
# - wsl
52+
# - gocognit
53+
- wastedassign
54+
- whitespace
55+
- nolintlint
56+
- asciicheck
57+
- dupword
58+
59+
issues:
60+
exclude-rules:
61+
- path: _test\.go
62+
linters:
63+
- gosec
64+
- revive
65+
- linters:
66+
- lll
67+
source: "https://"
68+
max-same-issues: 50
69+
70+
linters-settings:
71+
dogsled:
72+
max-blank-identifiers: 3
73+
golint:
74+
min-confidence: 0
75+
maligned:
76+
suggest-new: true
77+
misspell:
78+
locale: US
79+
goimports:
80+
local-prefixes: github.com/celestiaorg
81+
dupl:
82+
threshold: 200
83+
gofumpt:
84+
extra-rules: true

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ deps:
1616
## fmt: Formats only *.go (excluding *.pb.go *pb_test.go). Runs `gofmt & goimports` internally.
1717
fmt: sort-imports
1818
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s
19-
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/celestiaorg
19+
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/celestiaorg
2020
@go mod tidy
21+
@gofumpt -w -extra .
2122
@cfmt -w -m=100 ./...
2223
@markdownlint --fix --quiet --config .markdownlint.yaml .
2324
.PHONY: sort-imports

header.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Header[H any] interface {
1212
// New creates new instance of a header.
1313
// It exists to overcome limitation of Go's type system.
1414
// See:
15-
//https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#pointer-method-example
15+
// https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#pointer-method-example
1616
New() H
1717
// IsZero reports whether Header is a zero value of it's concrete type.
1818
IsZero() bool

p2p/server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import (
1919
p2p_pb "github.com/celestiaorg/go-header/p2p/pb"
2020
)
2121

22-
var (
23-
tracerServ = otel.Tracer("header/server")
24-
)
22+
var tracerServ = otel.Tracer("header/server")
2523

2624
// ExchangeServer represents the server-side component for
2725
// responding to inbound header-related requests.

p2p/session.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import (
1818
p2p_pb "github.com/celestiaorg/go-header/p2p/pb"
1919
)
2020

21-
var (
22-
tracerSession = otel.Tracer("header/p2p-session")
23-
)
21+
var tracerSession = otel.Tracer("header/p2p-session")
2422

2523
// errEmptyResponse means that server side closes the connection without sending at least 1
2624
// response.

store/keys.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import (
88
"github.com/celestiaorg/go-header"
99
)
1010

11-
var (
12-
headKey = datastore.NewKey("head")
13-
)
11+
var headKey = datastore.NewKey("head")
1412

1513
func heightKey(h uint64) datastore.Key {
1614
return datastore.NewKey(strconv.Itoa(int(h)))

sync/sync_head_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func TestSyncer_incomingNetworkHeadRaces(t *testing.T) {
4545

4646
wg.Wait()
4747
assert.EqualValues(t, 1, hits.Load())
48-
4948
}
5049

5150
// TestSyncer_HeadWithTrustedHead tests whether the syncer
@@ -122,12 +121,12 @@ func (t *wrappedGetter) Head(ctx context.Context, options ...header.HeadOption[*
122121
}
123122

124123
func (t *wrappedGetter) Get(ctx context.Context, hash header.Hash) (*headertest.DummyHeader, error) {
125-
//TODO implement me
124+
// TODO implement me
126125
panic("implement me")
127126
}
128127

129128
func (t *wrappedGetter) GetByHeight(ctx context.Context, u uint64) (*headertest.DummyHeader, error) {
130-
//TODO implement me
129+
// TODO implement me
131130
panic("implement me")
132131
}
133132

@@ -136,6 +135,6 @@ func (t *wrappedGetter) GetRangeByHeight(
136135
from *headertest.DummyHeader,
137136
to uint64,
138137
) ([]*headertest.DummyHeader, error) {
139-
//TODO implement me
138+
// TODO implement me
140139
panic("implement me")
141140
}

0 commit comments

Comments
 (0)