From 4852e3053b63591da5e4e40cbfa8fcfe8fa020a3 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 22 Apr 2024 13:29:51 +0400 Subject: [PATCH] use -extra flag for gofumpt --- .golangci.yml | 2 ++ Makefile | 2 +- api/docgen/openrpc.go | 2 +- api/gateway/bindings_test.go | 2 +- api/rpc/client/client.go | 2 +- api/rpc/server.go | 2 +- das/options.go | 2 +- nodebuilder/config.go | 2 +- nodebuilder/p2p/addrs.go | 2 +- nodebuilder/store.go | 2 +- nodebuilder/store_test.go | 6 +++--- share/availability/light/sample.go | 4 ++-- 12 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 09a44ef58f..89ea8d18ed 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -68,3 +68,5 @@ linters-settings: local-prefixes: github.com/celestiaorg/celestia-node dupl: threshold: 200 + gofumpt: + extra-rules: true diff --git a/Makefile b/Makefile index a1011ec9ee..ec041ea8b5 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ fmt: sort-imports @find . -name '*.go' -type f -not -path "*.git*" -not -name '*.pb.go' -not -name '*pb_test.go' | xargs gofmt -w -s @go mod tidy -compat=1.20 @cfmt -w -m=100 ./... - @gofumpt -w . + @gofumpt -w -extra . @markdownlint --fix --quiet --config .markdownlint.yaml . .PHONY: fmt diff --git a/api/docgen/openrpc.go b/api/docgen/openrpc.go index 4ec98d73b0..4af6b787b1 100644 --- a/api/docgen/openrpc.go +++ b/api/docgen/openrpc.go @@ -92,7 +92,7 @@ func ParseCommentsFromNodebuilderModules(moduleNames ...string) (Comments, Comme return nodeComments, permComments } -func NewOpenRPCDocument(comments Comments, permissions Comments) *go_openrpc_reflect.Document { +func NewOpenRPCDocument(comments, permissions Comments) *go_openrpc_reflect.Document { d := &go_openrpc_reflect.Document{} d.WithMeta(&go_openrpc_reflect.MetaT{ diff --git a/api/gateway/bindings_test.go b/api/gateway/bindings_test.go index ffd986d17d..e942c174bd 100644 --- a/api/gateway/bindings_test.go +++ b/api/gateway/bindings_test.go @@ -86,7 +86,7 @@ func TestRegisterEndpoints(t *testing.T) { } } -func hasEndpointRegistered(router *mux.Router, path string, method string) bool { +func hasEndpointRegistered(router *mux.Router, path, method string) bool { var registered bool err := router.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error { template, err := route.GetPathTemplate() diff --git a/api/rpc/client/client.go b/api/rpc/client/client.go index 1d8142048b..ff206d723e 100644 --- a/api/rpc/client/client.go +++ b/api/rpc/client/client.go @@ -63,7 +63,7 @@ func (c *Client) Close() { // NewClient creates a new Client with one connection per namespace with the // given token as the authorization token. -func NewClient(ctx context.Context, addr string, token string) (*Client, error) { +func NewClient(ctx context.Context, addr, token string) (*Client, error) { authHeader := http.Header{perms.AuthKey: []string{fmt.Sprintf("Bearer %s", token)}} return newClient(ctx, addr, authHeader) } diff --git a/api/rpc/server.go b/api/rpc/server.go index f247682083..0bcc9325c0 100644 --- a/api/rpc/server.go +++ b/api/rpc/server.go @@ -61,7 +61,7 @@ func (s *Server) verifyAuth(_ context.Context, token string) ([]auth.Permission, // RegisterService registers a service onto the RPC server. All methods on the service will then be // exposed over the RPC. -func (s *Server) RegisterService(namespace string, service interface{}, out interface{}) { +func (s *Server) RegisterService(namespace string, service, out interface{}) { if s.authDisabled { s.rpc.Register(namespace, service) return diff --git a/das/options.go b/das/options.go index 69deab52da..0e53eeaa97 100644 --- a/das/options.go +++ b/das/options.go @@ -13,7 +13,7 @@ var ErrInvalidOption = errors.New("das: invalid option") // errInvalidOptionValue is a utility function to dedup code for error-returning // when dealing with invalid parameter values -func errInvalidOptionValue(optionName string, value string) error { +func errInvalidOptionValue(optionName, value string) error { return fmt.Errorf("%w: value %s cannot be %s", ErrInvalidOption, optionName, value) } diff --git a/nodebuilder/config.go b/nodebuilder/config.go index bf9b1a5bfe..f73466e825 100644 --- a/nodebuilder/config.go +++ b/nodebuilder/config.go @@ -155,7 +155,7 @@ func UpdateConfig(tp node.Type, path string) (err error) { // updateConfig merges new values from the new config into the old // config, returning the updated old config. -func updateConfig(oldCfg *Config, newCfg *Config) (*Config, error) { +func updateConfig(oldCfg, newCfg *Config) (*Config, error) { err := mergo.Merge(oldCfg, newCfg, mergo.WithOverrideEmptySlice) return oldCfg, err } diff --git a/nodebuilder/p2p/addrs.go b/nodebuilder/p2p/addrs.go index d8f50c8144..0fb29008e0 100644 --- a/nodebuilder/p2p/addrs.go +++ b/nodebuilder/p2p/addrs.go @@ -23,7 +23,7 @@ func Listen(listen []string) func(h hst.Host) (err error) { } // addrsFactory returns a constructor for AddrsFactory. -func addrsFactory(announce []string, noAnnounce []string) func() (_ p2pconfig.AddrsFactory, err error) { +func addrsFactory(announce, noAnnounce []string) func() (_ p2pconfig.AddrsFactory, err error) { return func() (_ p2pconfig.AddrsFactory, err error) { // Convert maAnnounce strings to Multiaddresses maAnnounce := make([]ma.Multiaddr, len(announce)) diff --git a/nodebuilder/store.go b/nodebuilder/store.go index b9ff165a96..9d8af29075 100644 --- a/nodebuilder/store.go +++ b/nodebuilder/store.go @@ -185,7 +185,7 @@ func DiscoverOpened() (string, error) { // DefaultNodeStorePath constructs the default node store path using the given // node type and network. -var DefaultNodeStorePath = func(tp string, network string) (string, error) { +var DefaultNodeStorePath = func(tp, network string) (string, error) { home := os.Getenv("CELESTIA_HOME") if home == "" { diff --git a/nodebuilder/store_test.go b/nodebuilder/store_test.go index 64c41de66a..17d15f8a6f 100644 --- a/nodebuilder/store_test.go +++ b/nodebuilder/store_test.go @@ -167,7 +167,7 @@ func TestDiscoverOpened(t *testing.T) { t.Run("single open store", func(t *testing.T) { _, dir := initAndOpenStore(t, node.Full) - mockDefaultNodeStorePath := func(t string, n string) (string, error) { + mockDefaultNodeStorePath := func(t, n string) (string, error) { return dir, nil } DefaultNodeStorePath = mockDefaultNodeStorePath @@ -193,7 +193,7 @@ func TestDiscoverOpened(t *testing.T) { } } - mockDefaultNodeStorePath := func(tp string, n string) (string, error) { + mockDefaultNodeStorePath := func(tp, n string) (string, error) { key := n + "_" + tp if dir, ok := dirMap[key]; ok { return dir, nil @@ -218,7 +218,7 @@ func TestDiscoverOpened(t *testing.T) { t.Run("no opened store", func(t *testing.T) { dir := t.TempDir() - mockDefaultNodeStorePath := func(t string, n string) (string, error) { + mockDefaultNodeStorePath := func(t, n string) (string, error) { return dir, nil } DefaultNodeStorePath = mockDefaultNodeStorePath diff --git a/share/availability/light/sample.go b/share/availability/light/sample.go index e09a46a5fc..c8061cdb1e 100644 --- a/share/availability/light/sample.go +++ b/share/availability/light/sample.go @@ -15,7 +15,7 @@ type Sample struct { // SampleSquare randomly picks *num* unique points from the given *width* square // and returns them as samples. -func SampleSquare(squareWidth int, num int) ([]Sample, error) { +func SampleSquare(squareWidth, num int) ([]Sample, error) { ss := newSquareSampler(squareWidth, num) err := ss.generateSample(num) if err != nil { @@ -29,7 +29,7 @@ type squareSampler struct { smpls map[Sample]struct{} } -func newSquareSampler(squareWidth int, expectedSamples int) *squareSampler { +func newSquareSampler(squareWidth, expectedSamples int) *squareSampler { return &squareSampler{ squareWidth: squareWidth, smpls: make(map[Sample]struct{}, expectedSamples),