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

*: bump golangci-lint-action #2454

Merged
merged 9 commits into from
Jul 25, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
go-version: '1.20.6'
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@master
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.2
version: v1.52.2
- name: notify failure
if: failure() && github.ref == 'refs/heads/main'
env:
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ linters-settings:
disabled: true
- name: cognitive-complexity
disabled: true
- name: comment-spacings
xenowits marked this conversation as resolved.
Show resolved Hide resolved
disabled: true # Doesn't support latest go spec comments
# Some configured revive rules
- name: unhandled-error
arguments:
Expand Down
2 changes: 1 addition & 1 deletion app/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func SkipWrap(err error, msg string, skip int, fields ...z.Field) error {
}

return structured{
err: fmt.Errorf("%s: %w", msg, err), //nolint: forbidigo // Wrap error message using stdlib.
err: fmt.Errorf("%s: %w", msg, err), //nolint:forbidigo // Wrap error message using stdlib.
fields: fields,
stack: stack,
}
Expand Down
2 changes: 1 addition & 1 deletion app/errors/go113.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Is(err, target error) bool { return stderrors.Is(err, target) }
// repeatedly calling Unwrap.
//
// An error matches target if the error's concrete value is assignable to the value
// pointed to by target, or if the error has a method As(interface{}) bool such that
// pointed to by target, or if the error has a method As(any) bool such that
// As(target) returns true. In the latter case, the As method is responsible for
// setting target.
//
Expand Down
2 changes: 1 addition & 1 deletion app/tracer/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestStdOutTracer(t *testing.T) {

require.NoError(t, stop(ctx))

var m map[string]interface{}
var m map[string]any
d := json.NewDecoder(&buf)

err = d.Decode(&m)
Expand Down
2 changes: 1 addition & 1 deletion app/z/zapfield.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func F64(key string, val float64) Field {

// Any returns a wrapped zap string field with the string version of value.
// Note we are not using zap.Any since logfmt formatter doesn't support it.
func Any(key string, val interface{}) Field {
func Any(key string, val any) Field {
return func(add func(zap.Field)) {
add(zap.String(key, fmt.Sprint(val)))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/markdown_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestTrackerReasonReference(t *testing.T) {
writeMarkdown(t, "../docs/reasons.md", tpl, reasons)
}

func writeMarkdown(t *testing.T, file string, tpl *template.Template, data interface{}) {
func writeMarkdown(t *testing.T, file string, tpl *template.Template, data any) {
t.Helper()

var buf bytes.Buffer
Expand Down
52 changes: 26 additions & 26 deletions core/validatorapi/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (a apiError) Error() string {

// handlerFunc is a convenient handler function providing a context, parsed path parameters,
// the request body, and returning the response struct or an error.
type handlerFunc func(ctx context.Context, params map[string]string, query url.Values, typ contentType, body []byte) (res interface{}, headers http.Header, err error)
type handlerFunc func(ctx context.Context, params map[string]string, query url.Values, typ contentType, body []byte) (res any, headers http.Header, err error)

// wrap adapts the handler function returning a standard http handler.
// It does tracing, metrics and response and error writing.
Expand Down Expand Up @@ -283,7 +283,7 @@ func wrap(endpoint string, handler handlerFunc) http.Handler {
}

// writeResponse writes the 200 OK response and json response body.
func writeResponse(ctx context.Context, w http.ResponseWriter, endpoint string, response interface{}, headers http.Header) {
func writeResponse(ctx context.Context, w http.ResponseWriter, endpoint string, response any, headers http.Header) {
if response == nil {
return
}
Expand Down Expand Up @@ -315,7 +315,7 @@ func wrapTrace(endpoint string, handler http.HandlerFunc) http.Handler {

// getValidator returns a handler function for the get validators by pubkey or index endpoint.
func getValidators(p eth2client.ValidatorsProvider) handlerFunc {
return func(ctx context.Context, params map[string]string, query url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, params map[string]string, query url.Values, _ contentType, _ []byte) (any, http.Header, error) {
stateID := params["state_id"]

resp, err := getValidatorsByID(ctx, p, stateID, getValidatorIDs(query)...)
Expand All @@ -331,7 +331,7 @@ func getValidators(p eth2client.ValidatorsProvider) handlerFunc {

// getValidator returns a handler function for the get validators by pubkey or index endpoint.
func getValidator(p eth2client.ValidatorsProvider) handlerFunc {
return func(ctx context.Context, params map[string]string, _ url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, params map[string]string, _ url.Values, _ contentType, _ []byte) (any, http.Header, error) {
stateID := params["state_id"]
id := params["validator_id"]

Expand All @@ -353,7 +353,7 @@ func getValidator(p eth2client.ValidatorsProvider) handlerFunc {

// attestationData returns a handler function for the attestation data endpoint.
func attestationData(p eth2client.AttestationDataProvider) handlerFunc {
return func(ctx context.Context, _ map[string]string, query url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, query url.Values, _ contentType, _ []byte) (any, http.Header, error) {
slot, err := uintQuery(query, "slot")
if err != nil {
return nil, nil, err
Expand All @@ -379,7 +379,7 @@ func attestationData(p eth2client.AttestationDataProvider) handlerFunc {

// submitAttestations returns a handler function for the attestation submitter endpoint.
func submitAttestations(p eth2client.AttestationsSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
var atts []*eth2p0.Attestation
err := unmarshal(typ, body, &atts)
if err != nil {
Expand All @@ -392,7 +392,7 @@ func submitAttestations(p eth2client.AttestationsSubmitter) handlerFunc {

// proposerDuties returns a handler function for the proposer duty endpoint.
func proposerDuties(p eth2client.ProposerDutiesProvider) handlerFunc {
return func(ctx context.Context, params map[string]string, _ url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, params map[string]string, _ url.Values, _ contentType, _ []byte) (any, http.Header, error) {
epoch, err := uintParam(params, "epoch")
if err != nil {
return nil, nil, err
Expand All @@ -417,7 +417,7 @@ func proposerDuties(p eth2client.ProposerDutiesProvider) handlerFunc {

// attesterDuties returns a handler function for the attester duty endpoint.
func attesterDuties(p eth2client.AttesterDutiesProvider) handlerFunc {
return func(ctx context.Context, params map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, params map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
epoch, err := uintParam(params, "epoch")
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -445,7 +445,7 @@ func attesterDuties(p eth2client.AttesterDutiesProvider) handlerFunc {

// syncCommitteeDuties returns a handler function for the sync committee duty endpoint.
func syncCommitteeDuties(p eth2client.SyncCommitteeDutiesProvider) handlerFunc {
return func(ctx context.Context, params map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, params map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
epoch, err := uintParam(params, "epoch")
if err != nil {
return nil, nil, err
Expand All @@ -469,7 +469,7 @@ func syncCommitteeDuties(p eth2client.SyncCommitteeDutiesProvider) handlerFunc {

// syncCommitteeContribution returns a handler function for get sync committee contribution endpoint.
func syncCommitteeContribution(s eth2client.SyncCommitteeContributionProvider) handlerFunc {
return func(ctx context.Context, _ map[string]string, query url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, query url.Values, _ contentType, _ []byte) (any, http.Header, error) {
slot, err := uintQuery(query, "slot")
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -497,7 +497,7 @@ func syncCommitteeContribution(s eth2client.SyncCommitteeContributionProvider) h

// submitContributionAndProofs returns a handler function for sync committee contributions submitter endpoint.
func submitContributionAndProofs(s eth2client.SyncCommitteeContributionsSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
var contributionAndProofs []*altair.SignedContributionAndProof
err := unmarshal(typ, body, &contributionAndProofs)
if err != nil {
Expand All @@ -510,7 +510,7 @@ func submitContributionAndProofs(s eth2client.SyncCommitteeContributionsSubmitte

// proposeBlock receives the randao from the validator and returns the unsigned BeaconBlock.
func proposeBlock(p eth2client.BeaconBlockProposalProvider) handlerFunc {
return func(ctx context.Context, params map[string]string, query url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, params map[string]string, query url.Values, _ contentType, _ []byte) (any, http.Header, error) {
slot, err := uintParam(params, "slot")
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -588,7 +588,7 @@ func proposeBlock(p eth2client.BeaconBlockProposalProvider) handlerFunc {

// proposeBlindedBlock receives the randao from the validator and returns the unsigned BlindedBeaconBlock.
func proposeBlindedBlock(p eth2client.BlindedBeaconBlockProposalProvider) handlerFunc {
return func(ctx context.Context, params map[string]string, query url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, params map[string]string, query url.Values, _ contentType, _ []byte) (any, http.Header, error) {
slot, err := uintParam(params, "slot")
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -642,7 +642,7 @@ func proposeBlindedBlock(p eth2client.BlindedBeaconBlockProposalProvider) handle
}

func submitBlock(p eth2client.BeaconBlockSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
capellaBlock := new(capella.SignedBeaconBlock)
err := unmarshal(typ, body, capellaBlock)
if err == nil {
Expand Down Expand Up @@ -692,7 +692,7 @@ func submitBlock(p eth2client.BeaconBlockSubmitter) handlerFunc {
}

func submitBlindedBlock(p eth2client.BlindedBeaconBlockSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
// The blinded block maybe either bellatrix or capella.
capellaBlock := new(eth2capella.SignedBlindedBeaconBlock)
err := unmarshal(typ, body, capellaBlock)
Expand Down Expand Up @@ -722,7 +722,7 @@ func submitBlindedBlock(p eth2client.BlindedBeaconBlockSubmitter) handlerFunc {

// submitValidatorRegistrations returns a handler function for the validator (builder) registration submitter endpoint.
func submitValidatorRegistrations(r eth2client.ValidatorRegistrationsSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
var unversioned []*eth2v1.SignedValidatorRegistration
if err := unmarshal(typ, body, &unversioned); err != nil {
return nil, nil, errors.Wrap(err, "unmarshal signed builder registration")
Expand All @@ -742,7 +742,7 @@ func submitValidatorRegistrations(r eth2client.ValidatorRegistrationsSubmitter)

// aggregateBeaconCommitteeSelections receives partial beacon committee selections and returns aggregated selections.
func aggregateBeaconCommitteeSelections(a eth2exp.BeaconCommitteeSelectionAggregator) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (res interface{}, headers http.Header, err error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (res any, headers http.Header, err error) {
var selections []*eth2exp.BeaconCommitteeSelection
if err := unmarshal(typ, body, &selections); err != nil {
return nil, nil, errors.Wrap(err, "unmarshal beacon committee selections")
Expand All @@ -759,7 +759,7 @@ func aggregateBeaconCommitteeSelections(a eth2exp.BeaconCommitteeSelectionAggreg

// aggregateSyncCommitteeSelections receives partial sync committee selections and returns aggregated selections.
func aggregateSyncCommitteeSelections(a eth2exp.SyncCommitteeSelectionAggregator) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (res interface{}, headers http.Header, err error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (res any, headers http.Header, err error) {
var selections []*eth2exp.SyncCommitteeSelection
if err := unmarshal(typ, body, &selections); err != nil {
return nil, nil, errors.Wrap(err, "unmarshal sync committee selections")
Expand All @@ -776,7 +776,7 @@ func aggregateSyncCommitteeSelections(a eth2exp.SyncCommitteeSelectionAggregator

// submitExit returns a handler function for the exit submitter endpoint.
func submitExit(p eth2client.VoluntaryExitSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
exit := new(eth2p0.SignedVoluntaryExit)
if err := unmarshal(typ, body, exit); err != nil {
return nil, nil, errors.Wrap(err, "unmarshal signed voluntary exit")
Expand All @@ -787,7 +787,7 @@ func submitExit(p eth2client.VoluntaryExitSubmitter) handlerFunc {
}

func proposerConfig(p eth2exp.ProposerConfigProvider) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, _ contentType, _ []byte) (any, http.Header, error) {
resp, err := p.ProposerConfig(ctx)
if err != nil {
return nil, nil, errors.Wrap(err, "proposer config")
Expand All @@ -798,7 +798,7 @@ func proposerConfig(p eth2exp.ProposerConfigProvider) handlerFunc {
}

func aggregateAttestation(p eth2client.AggregateAttestationProvider) handlerFunc {
return func(ctx context.Context, _ map[string]string, query url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, query url.Values, _ contentType, _ []byte) (any, http.Header, error) {
slot, err := uintQuery(query, "slot")
if err != nil {
return nil, nil, err
Expand All @@ -823,7 +823,7 @@ func aggregateAttestation(p eth2client.AggregateAttestationProvider) handlerFunc
}

func submitAggregateAttestations(s eth2client.AggregateAttestationsSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
var aggs []*eth2p0.SignedAggregateAndProof
err := unmarshal(typ, body, &aggs)
if err != nil {
Expand All @@ -840,7 +840,7 @@ func submitAggregateAttestations(s eth2client.AggregateAttestationsSubmitter) ha
}

func submitSyncCommitteeMessages(s eth2client.SyncCommitteeMessagesSubmitter) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, typ contentType, body []byte) (any, http.Header, error) {
var msgs []*altair.SyncCommitteeMessage
err := unmarshal(typ, body, &msgs)
if err != nil {
Expand All @@ -859,14 +859,14 @@ func submitSyncCommitteeMessages(s eth2client.SyncCommitteeMessagesSubmitter) ha
// submitProposalPreparations swallows fee-recipient-address from validator client as it should be
// configured by charon from cluster-lock.json and VC need not be configured with correct fee-recipient-address.
func submitProposalPreparations() handlerFunc {
return func(context.Context, map[string]string, url.Values, contentType, []byte) (interface{}, http.Header, error) {
return func(context.Context, map[string]string, url.Values, contentType, []byte) (any, http.Header, error) {
return nil, nil, nil
}
}

// nodeVersion returns the version of the node.
func nodeVersion(p eth2client.NodeVersionProvider) handlerFunc {
return func(ctx context.Context, _ map[string]string, _ url.Values, _ contentType, _ []byte) (interface{}, http.Header, error) {
return func(ctx context.Context, _ map[string]string, _ url.Values, _ contentType, _ []byte) (any, http.Header, error) {
version, err := p.NodeVersion(ctx)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -999,7 +999,7 @@ func writeError(ctx context.Context, w http.ResponseWriter, endpoint string, err

// unmarshal parses body with the appropriate unmarshaler based on the contentType and stores the result
// in the value pointed to by v.
func unmarshal(typ contentType, body []byte, v interface{}) error {
func unmarshal(typ contentType, body []byte, v any) error {
if len(body) == 0 {
return apiError{
StatusCode: http.StatusBadRequest,
Expand Down
4 changes: 2 additions & 2 deletions core/validatorapi/router_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ func (h testHandler) newBeaconHandler(t *testing.T) http.Handler {
writeResponse(ctx, w, "", res, nil)
})
mux.HandleFunc("/eth/v1/config/spec", func(w http.ResponseWriter, r *http.Request) {
res := map[string]interface{}{
res := map[string]any{
"SLOTS_PER_EPOCH": fmt.Sprint(slotsPerEpoch),
}
writeResponse(ctx, w, "", nest(res, "data"), nil)
Expand Down Expand Up @@ -1291,7 +1291,7 @@ func (h testHandler) newBeaconHandler(t *testing.T) http.Handler {
}

// nest returns a json nested version the data objected. Note nests must be provided in inverse order.
func nest(data interface{}, nests ...string) interface{} {
func nest(data any, nests ...string) any {
res := data

for _, nest := range nests {
Expand Down
2 changes: 1 addition & 1 deletion eth2util/keymanager/keymanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type mockKeymanagerReq struct {

// noopKeystore is a mock keystore for use in tests.
type noopKeystore struct {
Crypto map[string]interface{} `json:"crypto"`
Crypto map[string]any `json:"crypto"`
}

// decrypt returns the secret from the encrypted keystore.
Expand Down
12 changes: 6 additions & 6 deletions eth2util/keystore/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ func storeKeysInternal(secrets []tbls.PrivateKey, dir string, filenameFmt string

// Keystore json file representation as a Go struct.
type Keystore struct {
Crypto map[string]interface{} `json:"crypto"`
Description string `json:"description"`
Pubkey string `json:"pubkey"`
Path string `json:"path"`
ID string `json:"uuid"`
Version uint `json:"version"`
Crypto map[string]any `json:"crypto"`
Description string `json:"description"`
Pubkey string `json:"pubkey"`
Path string `json:"path"`
ID string `json:"uuid"`
Version uint `json:"version"`
}

// Encrypt returns the secret as an encrypted Keystore using pbkdf2 cipher.
Expand Down
Loading
Loading