| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- version: "2"
- linters:
- default: none
- enable:
- # Malicious unicode characters that change the meaning are not in the source code.
- - bidichk
- # Ensure that the body is closed on HTTP and websocket conns
- - bodyclose
- - contextcheck
- - depguard
- # Duplicate word usage, such as 'and and' in a comment.
- - dupword
- - durationcheck
- - errcheck
- # Type assertion and comparison validation on errors. https://github.com/polyfloyd/go-errorlint
- - errorlint
- # Enum and maps used on switch statements are exhaustive
- - exhaustive
- - exhaustruct
- - forcetypeassert
- - gocritic
- - gosec
- - govet
- - ineffassign
- - loggercheck
- # Check for simple misspellings of words.
- - misspell
- - noctx
- # Require explanations for nolint comments
- - nolintlint
- - prealloc
- # Overwriting predeclared Golang names such as 'len' and 'min'.
- - predeclared
- # Validate common mistakes in Golang, such as invalid time.Parse format, invalid regular expression, etc.
- - staticcheck
- - unparam
- # Unused constants, variables, functions and types
- - unused
- settings:
- depguard:
- # Rules to apply.
- #
- # Variables:
- # - File Variables
- # Use an exclamation mark `!` to negate a variable.
- # Example: `!$test` matches any file that is not a go test file.
- #
- # `$all` - matches all go files
- # `$test` - matches all go test files
- #
- # - Package Variables
- #
- # `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
- #
- # Default (applies if no custom rules are defined): Only allow $gostd in all files.
- rules:
- # Name of a rule.
- main:
- # Defines package matching behavior. Available modes:
- # - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty.
- # - `strict`: allowed only if it matches the allow list and either doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
- # - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
- # Default: "original"
- list-mode: lax
- # List of file globs that will match this list of settings to compare against.
- # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed.
- # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`.
- # The placeholder '${config-path}' is substituted with a path relative to the configuration file.
- # Default: $all
- # files:
- # - "!**/*_a _file.go"
- # List of allowed packages.
- # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
- # Default: []
- # allow:
- # List of packages that are not allowed.
- # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
- # Default: []
- deny:
- # Debugging can be done without an external dependency.
- - pkg: "github.com/davecgh/go-spew/spew"
- desc: Use a custom formatter e.g. JSON
- # Unmaintained.
- - pkg: "github.com/benbjohnson/clock"
- desc: deprecated
- # Unnecessary for most use cases.
- - pkg: "github.com/mitchellh/go-homedir"
- desc: Use os.UserHomeDir()
- # Unmaintained.
- - pkg: "gopkg.in/godo.v2/watcher/fswatch"
- desc: Use package fsnotify/fsnotify
- - pkg: "github.com/pkg/errors"
- desc: Should be replaced by standard lib errors package
- errorlint:
- errorf: false
- exhaustive:
- # Program elements to check for exhaustiveness.
- # Default: [ switch ]
- check:
- - switch
- - map
- ignore-enum-types: "vaa.ChainID" # This type is used all over and doesn't need to be exhaustive
- #default-signifies-exhaustive: true
- exhaustruct:
- include:
- # List of regular expressions to match struct packages and their names.
- # Regular expressions must match complete canonical struct package/name/structname.
- # If this list is empty, all structs are tested.
- # Default: []
- - ./+governor.tokenConfigEntry$
- # TODO: MessagePublications _should_ be exhaustive but this will require many changes.
- - ./_common.MessagePublication$
- exclude:
- - .+/cobra\.Command$
- - .+/http\.Client$
- - .+/prometheus.+
- gocritic:
- disable-all: true
- # disabled-checks:
- # - exitAfterDefer
- # - assignOp
- # - ifElseChain
- # - elseif
- enabled-checks:
- - argOrder
- - badCall
- - badCond
- - badLock
- - badRegexp
- - badSorting
- - builtinShadow
- - builtinShadowDecl
- - caseOrder
- - dupArg
- - dupBranchBody
- - dupCase
- - dupSubExpr
- - externalErrorReassign
- - importShadow
- - mapKey
- - newDeref
- - offBy1
- - regexpPattern
- - sloppyReassign
- - truncateCmp
- - uncheckedInlineErr
- - weakCond
- # performance lints
- - indexAlloc
- nolintlint:
- # Disable to ensure that all nolint directives actually have an effect.
- # Default: false
- allow-unused: false
- # Exclude following linters from requiring an explanation.
- # Default: []
- allow-no-explanation: [dupWord]
- # Enable to require an explanation of nonzero length after each nolint directive.
- # Default: false
- require-explanation: true
- # Enable to require nolint directives to mention the specific linter being suppressed.
- # Default: false
- require-specific: true
- staticcheck:
- checks:
- # All of these lints should eventually be added.
- # They occurred during the migration to v2 and were disabled to make the upgrade easier.
- # https://golangci-lint.run/usage/linters/#staticcheck
- ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-SA9003", "-QF1003", "-QF1006", "-QF1008", "-QF1011", "-S1009", "-ST1017", "-ST1018", "-ST1019", "-ST1023"]
- unparam:
- # Inspect exported functions.
- #
- # Set to true if no external program/library imports your code.
- # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
- # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
- # with golangci-lint call it on a directory with the changed file.
- #
- # Default: false
- check-exported: true
- exclusions:
- generated: lax
- presets:
- - comments
- - common-false-positives
- - legacy
- - std-error-handling
- rules:
- # This file contains hard-coded Sui core contract addresses that are marked as hardcoded credentials.
- - path: pkg/txverifier/sui_test.go
- text: 'G101: Potential hardcoded credentials'
- - linters:
- - dupword
- - misspell
- path: .*generated_mainnet_tokens\.go$
- text: ".*" # This matches any text in the file
- - linters:
- - godox
- path: node/hack/
- # Ignore test files for these tools.
- - linters:
- - contextcheck
- - dupWord
- - exhaustruct
- - nolintlint
- path: _test\.go
- - linters:
- - exhaustruct
- path: (?i).*mock.*
- paths:
- - third_party$
- - builtin$
- - examples$
- issues:
- max-issues-per-linter: 0
- # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
- max-same-issues: 0
- formatters:
- exclusions:
- generated: lax
- paths:
- - third_party$
- - builtin$
- - examples$
|