Skip to content

Commit

Permalink
Linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed May 7, 2024
1 parent c42da2d commit bb39f4b
Show file tree
Hide file tree
Showing 52 changed files with 319 additions and 28 deletions.
86 changes: 71 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -68,7 +69,7 @@ run:
# Define the Go version limit.
# Mainly related to generics support since go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.18
go: '1.19'
# go: '1.20'


# output configuration options
Expand Down Expand Up @@ -108,6 +109,56 @@ linters-settings:
lll:
line-length: 132

revive:
ignore-generated-header: true
severity: error
confidence: 0.1
errorCode: 0
warningCode: 0
rules:
- name: atomic
- name: blank-imports
- name: comment-spacings
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: datarace
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: error-strings
- name: errorf
- name: exported
- name: file-header
- name: identical-branches
- name: import-alias-naming
- name: import-shadowing
- name: increment-decrement
- name: indent-error-flow
- name: modifies-value-receiver
- name: range-val-address
- name: range-val-in-closure
- name: range
- name: receiver-naming
- name: string-of-int
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: unchecked-type-assertion
- name: unhandled-error
arguments:
- "fmt.Fprint"
- "fmt.Fprintf"
- name: unnecessary-stmt
- name: unused-parameter
- name: unused-receiver
- name: use-any
- name: useless-break
- name: var-naming
- name: waitgroup-by-value

stylecheck:
checks: [ "all", "-ST1000" ]

Expand All @@ -129,25 +180,30 @@ linters:
- deadcode
- depguard
- dupl
- execinquery
- exhaustive
- exhaustivestruct
- exhaustruct
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- goerr113
- goheader
- gochecknoinits
- gocognit
- goconst
- err113
- golint
- gomnd
- ifshort
- interfacer
- ireturn
- lll
- maintidx
- maligned
- mnd
- musttag
- nilnil
- nlreturn
- nosnakecase
- rowserrcheck
- perfsprint
- scopelint
- structcheck
- varcheck
Expand Down
4 changes: 4 additions & 0 deletions api/bellatrix/builderbid.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (b *BuilderBid) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "invalid JSON")
}

return b.unpack(&data)
}

Expand Down Expand Up @@ -114,6 +115,7 @@ func (b *BuilderBid) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -124,6 +126,7 @@ func (b *BuilderBid) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return err
}

return b.unpack(&data)
}

Expand All @@ -133,5 +136,6 @@ func (b *BuilderBid) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
4 changes: 4 additions & 0 deletions api/bellatrix/signedbuilderbid.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (s *SignedBuilderBid) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "invalid JSON")
}

return s.unpack(&data)
}

Expand Down Expand Up @@ -89,6 +90,7 @@ func (s *SignedBuilderBid) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -99,6 +101,7 @@ func (s *SignedBuilderBid) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return err
}

return s.unpack(&data)
}

Expand All @@ -108,5 +111,6 @@ func (s *SignedBuilderBid) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
5 changes: 5 additions & 0 deletions api/bellatrix/submitblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *SubmitBlockRequest) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "invalid JSON")
}

return s.unpack(&data)
}

Expand All @@ -75,6 +76,7 @@ func (s *SubmitBlockRequest) unpack(data *submitBlockRequestJSON) error {
return errors.New("execution payload missing")
}
s.ExecutionPayload = data.ExecutionPayload

return nil
}

Expand All @@ -88,6 +90,7 @@ func (s *SubmitBlockRequest) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -98,6 +101,7 @@ func (s *SubmitBlockRequest) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return err
}

return s.unpack(&data)
}

Expand All @@ -107,5 +111,6 @@ func (s *SubmitBlockRequest) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
1 change: 1 addition & 0 deletions api/capella/builderbid.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ func (b *BuilderBid) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
1 change: 1 addition & 0 deletions api/capella/builderbid_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (b *BuilderBid) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "invalid JSON")
}

return b.unpack(&data)
}

Expand Down
2 changes: 2 additions & 0 deletions api/capella/builderbid_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (b *BuilderBid) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -49,5 +50,6 @@ func (b *BuilderBid) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return err
}

return b.unpack(&data)
}
1 change: 1 addition & 0 deletions api/capella/signedbuilderbid.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ func (s *SignedBuilderBid) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
1 change: 1 addition & 0 deletions api/capella/signedbuilderbid_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (s *SignedBuilderBid) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "invalid JSON")
}

return s.unpack(&data)
}

Expand Down
2 changes: 2 additions & 0 deletions api/capella/signedbuilderbid_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func (s *SignedBuilderBid) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -45,5 +46,6 @@ func (s *SignedBuilderBid) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return err
}

return s.unpack(&data)
}
1 change: 1 addition & 0 deletions api/capella/submitblockrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ func (s *SubmitBlockRequest) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
2 changes: 2 additions & 0 deletions api/capella/submitblockrequest_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (s *SubmitBlockRequest) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "invalid JSON")
}

return s.unpack(&data)
}

Expand All @@ -59,5 +60,6 @@ func (s *SubmitBlockRequest) unpack(data *submitBlockRequestJSON) error {
return errors.New("execution payload missing")
}
s.ExecutionPayload = data.ExecutionPayload

return nil
}
2 changes: 2 additions & 0 deletions api/capella/submitblockrequest_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (s *SubmitBlockRequest) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -36,5 +37,6 @@ func (s *SubmitBlockRequest) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return err
}

return s.unpack(&data)
}
1 change: 1 addition & 0 deletions api/deneb/blobsbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ func (b *BlobsBundle) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
5 changes: 3 additions & 2 deletions api/deneb/blobsbundle_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (b *BlobsBundle) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -64,10 +65,10 @@ func (b *BlobsBundle) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "failed to unmarshal YAML")
}
bytes, err := json.Marshal(data)
jsonBytes, err := json.Marshal(data)
if err != nil {
return errors.Wrap(err, "failed to marshal JSON")
}

return b.UnmarshalJSON(bytes)
return b.UnmarshalJSON(jsonBytes)
}
1 change: 1 addition & 0 deletions api/deneb/builderbid.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ func (b *BuilderBid) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
1 change: 1 addition & 0 deletions api/deneb/builderbid_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (b *BuilderBid) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &data); err != nil {
return errors.Wrap(err, "invalid JSON")
}

return b.unpack(&data)
}

Expand Down
2 changes: 2 additions & 0 deletions api/deneb/builderbid_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (b *BuilderBid) MarshalYAML() ([]byte, error) {
if err != nil {
return nil, err
}

return bytes.ReplaceAll(yamlBytes, []byte(`"`), []byte(`'`)), nil
}

Expand All @@ -50,5 +51,6 @@ func (b *BuilderBid) UnmarshalYAML(input []byte) error {
if err := yaml.Unmarshal(input, &data); err != nil {
return err
}

return b.unpack(&data)
}
1 change: 1 addition & 0 deletions api/deneb/executionpayloadandblobsbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ func (e *ExecutionPayloadAndBlobsBundle) String() string {
if err != nil {
return fmt.Sprintf("ERR: %v", err)
}

return string(data)
}
Loading

0 comments on commit bb39f4b

Please sign in to comment.