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

formatting: format code and imports with gci #2045

Open
wants to merge 4 commits into
base: stage
Choose a base branch
from
Open
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
21 changes: 13 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ run:

# output configuration options
output:
formats:
formats:
- format: colored-line-number

# print lines of code with issue, default is true
Expand All @@ -39,6 +39,16 @@ output:

# all available settings of specific linters
linters-settings:
gci:
sections:
- standard
- default
- blank
- dot
- localmodule
- prefix(github.com/ssvlabs/ssv-spec)
# various configuration options are listed here: https://golangci-lint.run/usage/linters/#gci
skip-generated: true
dogsled:
# checks assignments with too many blank identifiers; default is 2
max-blank-identifiers: 2
Expand Down Expand Up @@ -76,10 +86,6 @@ linters-settings:
funlen:
lines: 60
statements: 40
gci:
# Custom section: groups all imports with the specified Prefix.
sections:
- prefix(github.com/ssvlabs/ssv)
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
Expand Down Expand Up @@ -180,8 +186,6 @@ linters-settings:
- return
- assign
govet:


# settings per analyzer
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
Expand Down Expand Up @@ -328,6 +332,7 @@ linters:
- gosec
- errcheck
- errorlint
- gci

disable-all: false

Expand Down Expand Up @@ -405,4 +410,4 @@ issues:
# new-from-patch: path/to/patch/file

# Fix found issues (if it's supported by the linter)
fix: true
fix: false
Comment on lines 412 to +413
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe linter should be a read-only type of thing

6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,4 @@ mockgen-install:

.PHONY: format
format:
# both format commands must ignore generated files which are named *mock* or enr_fork_id_encoding.go
# the argument to gopls format can be a list of files
find . -name "*.go" ! -path '*mock*' ! -name 'enr_fork_id_encoding.go' -type f -print0 | xargs -0 -P 1 sh -c 'gopls -v format -w $0'
# the argument to gopls imports must be a single file so this entire command takes a few mintues to run
find . -name "*.go" ! -path '*mock*' ! -name 'enr_fork_id_encoding.go' -type f -print0 | xargs -0 -P 10 -I{} sh -c 'gopls -v imports -w "{}"'
gci write --skip-generated -s standard -s default -s blank -s dot -s localmodule -s "prefix(github.com/ssvlabs/ssv-spec)" $$(find . -type f -name '*.go')
5 changes: 3 additions & 2 deletions api/handlers/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"net/http"

"github.com/attestantio/go-eth2-client/spec/phase0"

spectypes "github.com/ssvlabs/ssv-spec/types"
"github.com/ssvlabs/ssv/networkconfig"
qbftstorage "github.com/ssvlabs/ssv/protocol/v2/qbft/storage"

"github.com/ssvlabs/ssv/api"
ibftstorage "github.com/ssvlabs/ssv/ibft/storage"
"github.com/ssvlabs/ssv/networkconfig"
qbftstorage "github.com/ssvlabs/ssv/protocol/v2/qbft/storage"
)

type Exporter struct {
Expand Down
2 changes: 2 additions & 0 deletions api/handlers/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"strings"

"github.com/attestantio/go-eth2-client/spec/phase0"

spectypes "github.com/ssvlabs/ssv-spec/types"

"github.com/ssvlabs/ssv/api"
"github.com/ssvlabs/ssv/protocol/v2/types"
registrystorage "github.com/ssvlabs/ssv/registry/storage"
Expand Down
1 change: 1 addition & 0 deletions api/handlers/validators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

spectypes "github.com/ssvlabs/ssv-spec/types"

"github.com/ssvlabs/ssv/protocol/v2/types"
)

Expand Down
3 changes: 2 additions & 1 deletion beacon/goclient/attest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import (
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/sourcegraph/conc/pool"
"github.com/ssvlabs/ssv-spec/types"
"github.com/stretchr/testify/require"
"go.uber.org/zap"

"github.com/ssvlabs/ssv-spec/types"

operatordatastore "github.com/ssvlabs/ssv/operator/datastore"
"github.com/ssvlabs/ssv/operator/slotticker"
"github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon"
Expand Down
5 changes: 3 additions & 2 deletions beacon/goclient/goclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import (
"github.com/jellydator/ttlcache/v3"
"github.com/pkg/errors"
"github.com/rs/zerolog"
specssv "github.com/ssvlabs/ssv-spec/ssv"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"
"tailscale.com/util/singleflight"

specssv "github.com/ssvlabs/ssv-spec/ssv"
spectypes "github.com/ssvlabs/ssv-spec/types"

"github.com/ssvlabs/ssv/logging/fields"
operatordatastore "github.com/ssvlabs/ssv/operator/datastore"
"github.com/ssvlabs/ssv/operator/slotticker"
Expand Down
3 changes: 2 additions & 1 deletion beacon/goclient/goclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import (
"github.com/attestantio/go-eth2-client/api"
v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ssvlabs/ssv-spec/types"
"github.com/stretchr/testify/require"
"go.uber.org/zap"

"github.com/ssvlabs/ssv-spec/types"

operatordatastore "github.com/ssvlabs/ssv/operator/datastore"
"github.com/ssvlabs/ssv/operator/slotticker"
"github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon"
Expand Down
1 change: 0 additions & 1 deletion beacon/goclient/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/spec/phase0"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
Expand Down
3 changes: 2 additions & 1 deletion beacon/goclient/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
"github.com/sourcegraph/conc/pool"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"

spectypes "github.com/ssvlabs/ssv-spec/types"

"github.com/ssvlabs/ssv/logging/fields"
"github.com/ssvlabs/ssv/operator/slotticker"
)
Expand Down
3 changes: 2 additions & 1 deletion beacon/goclient/signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
"github.com/pkg/errors"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"

spectypes "github.com/ssvlabs/ssv-spec/types"
)

func (gc *GoClient) computeVoluntaryExitDomain(ctx context.Context) (phase0.Domain, error) {
Expand Down
3 changes: 1 addition & 2 deletions beacon/goclient/sync_committee.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (

"github.com/attestantio/go-eth2-client/api"
eth2apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"go.uber.org/zap"

"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/phase0"
"go.uber.org/zap"
)

// SyncCommitteeDuties returns sync committee duties for a given epoch
Expand Down
3 changes: 2 additions & 1 deletion beacon/goclient/sync_committee_contribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

spectypes "github.com/ssvlabs/ssv-spec/types"
)

// IsSyncCommitteeAggregator returns tru if aggregator
Expand Down
8 changes: 3 additions & 5 deletions cli/bootnode/boot_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ import (
"fmt"
"log"

"github.com/ssvlabs/ssv/networkconfig"
"github.com/ssvlabs/ssv/utils/commons"

"github.com/ssvlabs/ssv/logging"

"github.com/ilyakaznacheev/cleanenv"
"github.com/spf13/cobra"
"go.uber.org/zap"

global_config "github.com/ssvlabs/ssv/cli/config"
"github.com/ssvlabs/ssv/logging"
"github.com/ssvlabs/ssv/networkconfig"
bootnode "github.com/ssvlabs/ssv/utils/boot_node"
"github.com/ssvlabs/ssv/utils/commons"
)

type config struct {
Expand Down
3 changes: 1 addition & 2 deletions cli/generate_operator_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"os"
"path/filepath"

"github.com/ssvlabs/ssv/operator/keystore"

"github.com/spf13/cobra"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/logging"
"github.com/ssvlabs/ssv/operator/keys"
"github.com/ssvlabs/ssv/operator/keystore"
)

var generateOperatorKeysCmd = &cobra.Command{
Expand Down
3 changes: 2 additions & 1 deletion cli/operator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
"github.com/ilyakaznacheev/cleanenv"
"github.com/pkg/errors"
"github.com/spf13/cobra"
spectypes "github.com/ssvlabs/ssv-spec/types"
"go.uber.org/zap"

spectypes "github.com/ssvlabs/ssv-spec/types"

"github.com/ssvlabs/ssv/api/handlers"
apiserver "github.com/ssvlabs/ssv/api/server"
"github.com/ssvlabs/ssv/beacon/goclient"
Expand Down
3 changes: 1 addition & 2 deletions cli/threshold.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
"github.com/spf13/cobra"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/cli/flags"
"github.com/ssvlabs/ssv/logging"
ssvtypes "github.com/ssvlabs/ssv/protocol/v2/types"
"github.com/ssvlabs/ssv/utils/threshold"

"github.com/ssvlabs/ssv/cli/flags"
)

// createThreshold is the command to create threshold based on the given private key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"crypto/rand"
"fmt"
"sort"

v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
"go.uber.org/zap"
"sort"
)

type AttesterSlashingTest struct {
Expand Down
3 changes: 2 additions & 1 deletion e2e/beacon_proxy/intercept/slashinginterceptor/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"crypto/rand"
"encoding/json"
"fmt"
"sort"

v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
"go.uber.org/zap"
"sort"
)

type ProposerSlashingTest struct {
Expand Down
2 changes: 1 addition & 1 deletion e2e/beacon_proxy/intercept/slashinginterceptor/slashing.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon"
"go.uber.org/zap"
"golang.org/x/exp/maps"

beaconproxy "github.com/ssvlabs/ssv/e2e/beacon_proxy"
"github.com/ssvlabs/ssv/protocol/v2/blockchain/beacon"
)

const startEndEpochsDiff = 2
Expand Down
2 changes: 1 addition & 1 deletion e2e/cmd/ssv-e2e/beacon_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
"github.com/attestantio/go-eth2-client/http"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/rs/zerolog"
"github.com/ssvlabs/ssv/networkconfig"
"go.uber.org/zap"
"golang.org/x/exp/maps"

beaconproxy "github.com/ssvlabs/ssv/e2e/beacon_proxy"
"github.com/ssvlabs/ssv/e2e/beacon_proxy/intercept/slashinginterceptor"
"github.com/ssvlabs/ssv/networkconfig"
)

type BeaconProxyCmd struct {
Expand Down
6 changes: 4 additions & 2 deletions e2e/cmd/ssv-e2e/share_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import (
"path/filepath"

"github.com/attestantio/go-eth2-client/spec/phase0"
"go.uber.org/zap"
"gopkg.in/yaml.v3"

"github.com/ssvlabs/ssv-spec/types"

"github.com/ssvlabs/ssv/e2e/logs_catcher"
"github.com/ssvlabs/ssv/ekm"
"github.com/ssvlabs/ssv/networkconfig"
Expand All @@ -18,8 +22,6 @@ import (
"github.com/ssvlabs/ssv/storage/kv"
"github.com/ssvlabs/ssv/utils/blskeygen"
"github.com/ssvlabs/ssv/utils/rsaencryption"
"go.uber.org/zap"
"gopkg.in/yaml.v3"
)

type ShareUpdateCmd struct {
Expand Down
6 changes: 4 additions & 2 deletions e2e/logs_catcher/docker/docker_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package docker
import (
"bufio"
"context"
"io"
"strings"

"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/pkg/errors"

"github.com/ssvlabs/ssv/e2e/logs_catcher/logs"
"io"
"strings"
)

type Streamer interface {
Expand Down
1 change: 1 addition & 0 deletions e2e/logs_catcher/docker/restarter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package docker

import (
"context"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
)
Expand Down
4 changes: 3 additions & 1 deletion e2e/logs_catcher/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package logs_catcher
import (
"context"
"fmt"

"github.com/pkg/errors"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/e2e/logs_catcher/docker"
"github.com/ssvlabs/ssv/e2e/logs_catcher/parser"
"go.uber.org/zap"
)

const MesasgeKey = "msg" // todo: pass to struct/load from config
Expand Down
3 changes: 2 additions & 1 deletion e2e/logs_catcher/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package logs_catcher
import (
"context"
"encoding/binary"
"io"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"io"
)

type mockDockerClient struct {
Expand Down
Loading