Skip to content

Commit

Permalink
chore: use gofumpt (#196)
Browse files Browse the repository at this point in the history
## Overview

Unify formatting with `celestia-node` and other Celestia projects in the
future.
  • Loading branch information
cristaloleg authored Jun 12, 2024
1 parent 72d6506 commit b81f0d7
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 15 deletions.
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 ./...
@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")
}

0 comments on commit b81f0d7

Please sign in to comment.