From d467a8ef9c386f85f581c0b50949d13e4262888d Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Tue, 18 Jun 2024 12:52:53 +0100 Subject: [PATCH] Linting. --- .golangci.yml | 29 ++++++++++------------------- cmd/block/analyze/process.go | 9 +++++---- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2655fb0..fe08351 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,16 @@ # This file is not a configuration example, # it contains the exhaustive configuration with explanations of the options. +issues: + # Which files to exclude: they will be analyzed, but issues from them won't be reported. + # There is no need to include all autogenerated files, + # we confidently recognize autogenerated files. + # If it's not, please let us know. + # "/" will be replaced by current OS file path separator to properly work on Windows. + # Default: [] + exclude-files: + - ".*_ssz\\.go$" + # Options for analysis running. run: # The default concurrency value is the number of available CPU. @@ -39,15 +49,6 @@ run: # Default: true # skip-dirs-use-default: false - # Which files to skip: they will be analyzed, but issues from them won't be reported. - # Default value is empty list, - # but there is no need to include all autogenerated files, - # we confidently recognize autogenerated files. - # If it's not please let us know. - # "/" will be replaced by current OS file path separator to properly work on Windows. - skip-files: - - ".*_ssz\\.go$" - # If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes @@ -127,14 +128,12 @@ linters: disable: - contextcheck - cyclop - - deadcode - depguard - dupl - err113 - errorlint - execinquery - exhaustive - - exhaustivestruct - exhaustruct - forbidigo - forcetypeassert @@ -145,29 +144,21 @@ linters: - gocognit - goconst - goheader - - golint - gomnd - - ifshort - - interfacer - ireturn - lll - maintidx - - maligned - mnd - musttag - nestif - nilnil - nlreturn - nolintlint - - nosnakecase - perfsprint - promlinter - rowserrcheck - - scopelint - sqlclosecheck - - structcheck - unparam - - varcheck - varnamelen - wastedassign - wrapcheck diff --git a/cmd/block/analyze/process.go b/cmd/block/analyze/process.go index 4173f48..40b2877 100644 --- a/cmd/block/analyze/process.go +++ b/cmd/block/analyze/process.go @@ -17,6 +17,7 @@ import ( "bytes" "context" "fmt" + "net/http" eth2client "github.com/attestantio/go-eth2-client" "github.com/attestantio/go-eth2-client/api" @@ -39,7 +40,7 @@ func (c *command) process(ctx context.Context) error { }) if err != nil { var apiError *api.Error - if errors.As(err, &apiError) && apiError.StatusCode == 404 { + if errors.As(err, &apiError) && apiError.StatusCode == http.StatusNotFound { return errors.New("empty beacon block") } return errors.Wrap(err, "failed to obtain beacon block") @@ -211,7 +212,7 @@ func (c *command) fetchParents(ctx context.Context, block *spec.VersionedSignedB }) if err != nil { var apiError *api.Error - if errors.As(err, &apiError) && apiError.StatusCode == 404 { + if errors.As(err, &apiError) && apiError.StatusCode == http.StatusNotFound { return errors.New("empty beacon block") } return err @@ -394,7 +395,7 @@ func (c *command) calcHeadCorrect(ctx context.Context, attestation *phase0.Attes }) if err != nil { var apiError *api.Error - if errors.As(err, &apiError) && apiError.StatusCode == 404 { + if errors.As(err, &apiError) && apiError.StatusCode == http.StatusNotFound { if c.debug { fmt.Printf("No block available for slot %d, assuming not in canonical chain", slot) } @@ -432,7 +433,7 @@ func (c *command) calcTargetCorrect(ctx context.Context, attestation *phase0.Att }) if err != nil { var apiError *api.Error - if errors.As(err, &apiError) && apiError.StatusCode == 404 { + if errors.As(err, &apiError) && apiError.StatusCode == http.StatusNotFound { if c.debug { fmt.Printf("No block available for slot %d, assuming not in canonical chain", slot) }