.golangci.yml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. version: "2"
  2. linters:
  3. default: none
  4. enable:
  5. # Malicious unicode characters that change the meaning are not in the source code.
  6. - bidichk
  7. # Ensure that the body is closed on HTTP and websocket conns
  8. - bodyclose
  9. - contextcheck
  10. - depguard
  11. # Duplicate word usage, such as 'and and' in a comment.
  12. - dupword
  13. - durationcheck
  14. - errcheck
  15. # Type assertion and comparison validation on errors. https://github.com/polyfloyd/go-errorlint
  16. - errorlint
  17. # Enum and maps used on switch statements are exhaustive
  18. - exhaustive
  19. - exhaustruct
  20. - forcetypeassert
  21. - gocritic
  22. - gosec
  23. - govet
  24. - ineffassign
  25. - loggercheck
  26. # Check for simple misspellings of words.
  27. - misspell
  28. - noctx
  29. # Require explanations for nolint comments
  30. - nolintlint
  31. - prealloc
  32. # Overwriting predeclared Golang names such as 'len' and 'min'.
  33. - predeclared
  34. # Validate common mistakes in Golang, such as invalid time.Parse format, invalid regular expression, etc.
  35. - staticcheck
  36. - unparam
  37. # Unused constants, variables, functions and types
  38. - unused
  39. settings:
  40. depguard:
  41. # Rules to apply.
  42. #
  43. # Variables:
  44. # - File Variables
  45. # Use an exclamation mark `!` to negate a variable.
  46. # Example: `!$test` matches any file that is not a go test file.
  47. #
  48. # `$all` - matches all go files
  49. # `$test` - matches all go test files
  50. #
  51. # - Package Variables
  52. #
  53. # `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
  54. #
  55. # Default (applies if no custom rules are defined): Only allow $gostd in all files.
  56. rules:
  57. # Name of a rule.
  58. main:
  59. # Defines package matching behavior. Available modes:
  60. # - `original`: allowed if it doesn't match the deny list and either matches the allow list or the allow list is empty.
  61. # - `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.
  62. # - `lax`: allowed if it doesn't match the deny list or the allow rule is more specific (longer) than the deny rule.
  63. # Default: "original"
  64. list-mode: lax
  65. # List of file globs that will match this list of settings to compare against.
  66. # By default, if a path is relative, it is relative to the directory where the golangci-lint command is executed.
  67. # The placeholder '${base-path}' is substituted with a path relative to the mode defined with `run.relative-path-mode`.
  68. # The placeholder '${config-path}' is substituted with a path relative to the configuration file.
  69. # Default: $all
  70. # files:
  71. # - "!**/*_a _file.go"
  72. # List of allowed packages.
  73. # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
  74. # Default: []
  75. # allow:
  76. # List of packages that are not allowed.
  77. # Entries can be a variable (starting with $), a string prefix, or an exact match (if ending with $).
  78. # Default: []
  79. deny:
  80. # Debugging can be done without an external dependency.
  81. - pkg: "github.com/davecgh/go-spew/spew"
  82. desc: Use a custom formatter e.g. JSON
  83. # Unmaintained.
  84. - pkg: "github.com/benbjohnson/clock"
  85. desc: deprecated
  86. # Unnecessary for most use cases.
  87. - pkg: "github.com/mitchellh/go-homedir"
  88. desc: Use os.UserHomeDir()
  89. # Unmaintained.
  90. - pkg: "gopkg.in/godo.v2/watcher/fswatch"
  91. desc: Use package fsnotify/fsnotify
  92. - pkg: "github.com/pkg/errors"
  93. desc: Should be replaced by standard lib errors package
  94. errorlint:
  95. errorf: false
  96. exhaustive:
  97. # Program elements to check for exhaustiveness.
  98. # Default: [ switch ]
  99. check:
  100. - switch
  101. - map
  102. ignore-enum-types: "vaa.ChainID" # This type is used all over and doesn't need to be exhaustive
  103. #default-signifies-exhaustive: true
  104. exhaustruct:
  105. include:
  106. # List of regular expressions to match struct packages and their names.
  107. # Regular expressions must match complete canonical struct package/name/structname.
  108. # If this list is empty, all structs are tested.
  109. # Default: []
  110. - ./+governor.tokenConfigEntry$
  111. - ./_common.MessagePublication$
  112. exclude:
  113. - .+/cobra\.Command$
  114. - .+/http\.Client$
  115. - .+/prometheus.+
  116. gocritic:
  117. disable-all: true
  118. # disabled-checks:
  119. # - exitAfterDefer
  120. # - assignOp
  121. # - ifElseChain
  122. # - elseif
  123. enabled-checks:
  124. - argOrder
  125. - badCall
  126. - badCond
  127. - badLock
  128. - badRegexp
  129. - badSorting
  130. - builtinShadow
  131. - builtinShadowDecl
  132. - caseOrder
  133. - dupArg
  134. - dupBranchBody
  135. - dupCase
  136. - dupSubExpr
  137. - externalErrorReassign
  138. - importShadow
  139. - mapKey
  140. - newDeref
  141. - offBy1
  142. - regexpPattern
  143. - sloppyReassign
  144. - truncateCmp
  145. - uncheckedInlineErr
  146. - weakCond
  147. # performance lints
  148. - indexAlloc
  149. nolintlint:
  150. # Disable to ensure that all nolint directives actually have an effect.
  151. # Default: false
  152. allow-unused: false
  153. # Exclude following linters from requiring an explanation.
  154. # Default: []
  155. allow-no-explanation: [dupWord]
  156. # Enable to require an explanation of nonzero length after each nolint directive.
  157. # Default: false
  158. require-explanation: true
  159. # Enable to require nolint directives to mention the specific linter being suppressed.
  160. # Default: false
  161. require-specific: true
  162. staticcheck:
  163. checks:
  164. # All of these lints should eventually be added.
  165. # They occurred during the migration to v2 and were disabled to make the upgrade easier.
  166. # https://golangci-lint.run/usage/linters/#staticcheck
  167. ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-SA9003", "-QF1003", "-QF1006", "-QF1008", "-QF1011", "-S1009", "-ST1017", "-ST1018", "-ST1019", "-ST1023"]
  168. unparam:
  169. # Inspect exported functions.
  170. #
  171. # Set to true if no external program/library imports your code.
  172. # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
  173. # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
  174. # with golangci-lint call it on a directory with the changed file.
  175. #
  176. # Default: false
  177. check-exported: true
  178. exclusions:
  179. generated: lax
  180. presets:
  181. - comments
  182. - common-false-positives
  183. - legacy
  184. - std-error-handling
  185. rules:
  186. # This file contains hard-coded Sui core contract addresses that are marked as hardcoded credentials.
  187. - path: pkg/txverifier/sui_test.go
  188. text: 'G101: Potential hardcoded credentials'
  189. - linters:
  190. - dupword
  191. - misspell
  192. path: .*generated_mainnet_tokens\.go$
  193. text: ".*" # This matches any text in the file
  194. - linters:
  195. - godox
  196. path: node/hack/
  197. # Ignore test files for these tools.
  198. - linters:
  199. - contextcheck
  200. - dupWord
  201. - exhaustruct
  202. - nolintlint
  203. path: _test\.go
  204. - linters:
  205. - exhaustruct
  206. path: (?i).*mock.*
  207. paths:
  208. - third_party$
  209. - builtin$
  210. - examples$
  211. issues:
  212. max-issues-per-linter: 0
  213. # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
  214. max-same-issues: 0
  215. formatters:
  216. exclusions:
  217. generated: lax
  218. paths:
  219. - third_party$
  220. - builtin$
  221. - examples$