diff --git a/.golangci-version b/.golangci-version new file mode 100644 index 0000000000..91951fd8ad --- /dev/null +++ b/.golangci-version @@ -0,0 +1 @@ +1.61.0 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000000..7cd45d3f22 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,151 @@ +run: + tests: true + skip-dirs-use-default: false + skip-dirs: + - grpc/client/rest/* + - bundle/* + - generated/* + - otelginmetrics/* + timeout: 15m + skip-files: + - '.*\\.abigen\\.go$' + - '.*\\.metadata\\.go$' + - '.*\\.pb\\.go$' + - '.*_gen.go$' + +linters-settings: + gofmt: + simplify: true + govet: + # Don't report about shadowed variables + check-shadowing: false + misspell: + locale: US + gocritic: + disabled-checks: + - appendAssign +linters: + enable-all: true + disable: + # Global variables are used in many places throughout the code base. + - gochecknoglobals + + # Some lines are over 80 characters on purpose and we don't want to make them + # even longer by marking them as 'nolint'. + - lll + + # We don't care (enough) about misaligned structs to lint that. + - maligned + + # We have long functions, especially in tests. Moving or renaming those would + # trigger funlen problems that we may not want to solve at that time. + - funlen + + # Disable for now as we haven't yet tuned the sensitivity to our codebase + # yet. Enabling by default for example, would also force new contributors to + # potentially extensively refactor code, when they want to smaller change to + # land. + - gocyclo + + # Instances of table driven tests that don't pre-allocate shouldn't trigger + # the linter. + - prealloc + + # Init functions are used by loggers throughout the codebase. + - gochecknoinits + # this messes with formatting + - goimports + # TODO implement paralell tests + - paralleltest + # remove + - wsl + # skip for post set + - exhaustruct + - exhaustivestruct + # if short + - ifshort + # we want to use todo + - godox + # skip new line return until autofix works for it + - nlreturn + # go 1.13 error + - goerr113 + # disable gci + - gci + # disable gofumpt + - gofumpt + # allow magic numbers + - gomnd + # allow println + - forbidigo + # disabled (todo: enable) + - interfacer + # Allow nolint + - nolintlint + # we use external json tags + - tagliatelle + # var name len + - varnamelen + # allow replacements + - gomoddirectives + # no need to disallow returning interfaces + - ireturn + - nonamedreturns + - contextcheck + - nosnakecase + - depguard + # we use core/testsuite.Err() etc that don't get caught by this linter and result in false positives. + - testifylint + # we use metrics.EndSpan and metrics.EndSpanWithErr so this gets triggered falsely + - spancheck + # simply annoying + - perfsprint + # malfunctions on embedded structs + - typecheck + # magic numbers + - gomnd + fast: false + +issues: + # We use dot imports extensively in tests. Usually for testify assertions + exclude-rules: + - path: _test\.go + linters: + - revive + - stylecheck + - dupl + # wrapping errors when exporting for testing is tedious + - path: export_test\.go + linters: + - wrapcheck + text: 'should not use dot imports' + - path: contracts/ + linters: + - revive + text: 'and that stutters; consider calling this' + - path: ethergo/example/* + linters: + - wrapcheck + - path: testutil/* + linters: + - wrapcheck + - path: ethergo/* + linters: + - staticcheck + text: 'SA1019' + - path: \.resolvers\.go + linters: + - cyclop + - path: signoz/* + linters: + - gomnd + - stylecheck + - path: example/* + linters: + - revive + - cyclop + - forcetypeassert + - staticcheck + - wrapcheck + exclude-use-default: false + new-from-rev: 9fe0f033b73acf6b8240f0a832c4b4d21e68181b