Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use gofumpt #196

Merged
merged 6 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
run:
timeout: 5m

linters:
enable:
- bidichk
- bodyclose
# - depguard as of v1.54.2, the default config throws errors on our repo
- dogsled
- dupl
- errcheck
- errorlint
# - funlen
# - gochecknoglobals
# - gochecknoinits
- exportloopref
- gocheckcompilerdirectives
- goconst
- gocritic
# - gocyclo
# - godox
- gofmt
- gofumpt
- goimports
# - golint - deprecated since v1.41. revive will be used instead
- revive
- gosec
- gosimple
- govet
- ineffassign
# - interfacer
- lll
- loggercheck
- misspell
# - maligned
- nakedret
- nilerr
- nilnil
- nolintlint
- prealloc
- protogetter
# - scopelint - deprecated since v1.39. exportloopref will be used instead
- exportloopref
- staticcheck
- stylecheck
- typecheck
- unconvert
# - unparam
- unused
# - whitespace
# - wsl
# - gocognit
- wastedassign
- whitespace
- nolintlint
- asciicheck
- dupword

issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
- revive
- linters:
- lll
source: "https://"
max-same-issues: 50

linters-settings:
dogsled:
max-blank-identifiers: 3
golint:
min-confidence: 0
maligned:
suggest-new: true
misspell:
locale: US
goimports:
local-prefixes: github.com/celestiaorg
dupl:
threshold: 200
gofumpt:
extra-rules: true
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ deps:
## fmt: Formats only *.go (excluding *.pb.go *pb_test.go). Runs `gofmt & goimports` internally.
fmt: sort-imports
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/celestiaorg
@find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs goimports -w -local github.com/celestiaorg
@go mod tidy
@gofumpt -w -extra .
@cfmt -w -m=100 ./...
cristaloleg marked this conversation as resolved.
Show resolved Hide resolved
cristaloleg marked this conversation as resolved.
Show resolved Hide resolved
@markdownlint --fix --quiet --config .markdownlint.yaml .
.PHONY: sort-imports
Expand Down
2 changes: 1 addition & 1 deletion header.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Header[H any] interface {
// New creates new instance of a header.
// It exists to overcome limitation of Go's type system.
// See:
//https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#pointer-method-example
// https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md#pointer-method-example
New() H
// IsZero reports whether Header is a zero value of it's concrete type.
IsZero() bool
Expand Down
4 changes: 1 addition & 3 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import (
p2p_pb "github.com/celestiaorg/go-header/p2p/pb"
)

var (
tracerServ = otel.Tracer("header/server")
)
var tracerServ = otel.Tracer("header/server")

// ExchangeServer represents the server-side component for
// responding to inbound header-related requests.
Expand Down
4 changes: 1 addition & 3 deletions p2p/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
p2p_pb "github.com/celestiaorg/go-header/p2p/pb"
)

var (
tracerSession = otel.Tracer("header/p2p-session")
)
var tracerSession = otel.Tracer("header/p2p-session")

// errEmptyResponse means that server side closes the connection without sending at least 1
// response.
Expand Down
4 changes: 1 addition & 3 deletions store/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"github.com/celestiaorg/go-header"
)

var (
headKey = datastore.NewKey("head")
)
var headKey = datastore.NewKey("head")

func heightKey(h uint64) datastore.Key {
return datastore.NewKey(strconv.Itoa(int(h)))
Expand Down
7 changes: 3 additions & 4 deletions sync/sync_head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestSyncer_incomingNetworkHeadRaces(t *testing.T) {

wg.Wait()
assert.EqualValues(t, 1, hits.Load())

}

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

func (t *wrappedGetter) Get(ctx context.Context, hash header.Hash) (*headertest.DummyHeader, error) {
//TODO implement me
// TODO implement me
panic("implement me")
}

func (t *wrappedGetter) GetByHeight(ctx context.Context, u uint64) (*headertest.DummyHeader, error) {
//TODO implement me
// TODO implement me
panic("implement me")
}

Expand All @@ -136,6 +135,6 @@ func (t *wrappedGetter) GetRangeByHeight(
from *headertest.DummyHeader,
to uint64,
) ([]*headertest.DummyHeader, error) {
//TODO implement me
// TODO implement me
panic("implement me")
}
Loading