forked from omni-network/omni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
158 lines (154 loc) · 6.45 KB
/
.golangci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
run:
timeout: 5m
go: "1.22"
skip-files:
- ".*\\.pb\\.go$" # Ignore generated protobuf files
skip-dirs:
- explorer/db/ent
linters-settings:
exhaustive:
default-signifies-exhaustive: true
forbidigo:
forbid:
- 'fmt\.Print.*(# Avoid debug logging)?'
- 'fmt\.Errorf.*(# Prefer lib/errors.Wrap)?'
- 'prometheus\.New.*(# Prefer promauto)?'
gci: # Auto-format imports
sections:
- standard # Go stdlib
- prefix(github.com/omni-network) # Omni
- prefix(github.com/cometbft) # CometBFT
- prefix(github.com/ethereum) # Go-Ethereum
- default # All other imports not matched to another section type.
- blank # Blank imports
custom-order: true
govet:
enable-all: true
importas:
no-unaliased: true
alias:
- pkg: github.com/cometbft/cometbft/crypto/secp256k1
alias: k1
# TODO(corver): Add our own import aliases here
misspell:
locale: US
nlreturn:
block-size: 2
nolintlint:
require-explanation: true
require-specific: true
revive:
enable-all-rules: true
severity: warning
ignore-generated-header: true
rules:
# Disabled revive rules
- name: file-header # Doesn't support auto fix
disabled: true
- name: max-public-structs # Too strict
disabled: true
- name: banned-characters # Not applicable
disabled: true
- name: cognitive-complexity # False positives, address in code reviews
disabled: true
- name: function-length # False positives, address in code reviews
disabled: true
- name: function-result-limit # False positives, address in code reviews
disabled: true
- name: cyclomatic # False positives, address in code reviews
disabled: true
- name: argument-limit # False positives, address in code reviews
disabled: true
- name: line-length-limit # Requires us to cause indentation confusion: https://google.github.io/styleguide/go/decisions#indentation-confusion
disabled: true
# Some configured revive rules
- name: imports-blacklist
arguments:
- "log" # Prefer ./lib/log
- "errors" # Prefer ./lib/errors
- "github.com/pkg/errors" # Prefer ./lib/errors
- "github.com/gogo/protobuf/proto" # Prefer google.golang.org/protobuf
- "github.com/stretchr/testify/assert" # Prefer github.com/stretchr/testify/require
- "golang.org/x/exp/slices" # Prefer slices
- name: unhandled-error
arguments:
- 'fmt.Printf'
- 'fmt.Println'
staticcheck:
checks:
- "all"
testpackage:
skip-regexp: internal_test\.go # Allow internal tests
wrapcheck:
ignoreSigs:
- github.com/omni-network/omni/
- google.golang.org/grpc/status # No point wrapping gRPC/network errors.
- github.com/ethereum/go-ethereum # We wrap these automatically in lib/ethclient
issues:
fix: true
exclude-rules:
- path: '(.*)(_test|tutil|scripts)(.*)'
linters: # Relax linters for both tests/scripts (non-production code)
- gosec # Security not required
- revive # Relax revive rules
- wrapcheck # Wrapping not required
- perfsprint # Performance not an issue here
- contextcheck # Context not an issue here
- maintidx # Relax linter for table driven tests
- dupl # Many tests share similar testing logic but call different methods with different args
- path: '(.*)(e2e)(.*)'
linters: # Relax linters for both e2e (performance not required)
- perfsprint # Performance not an issue here
- path: '(.*)(scripts|cli)(.*)'
linters: # Relax linters for scripts and clis
- forbidigo # Allow debug printing
exclude:
- add-constant # Ignore "add-constant: avoid magic numbers like" since it is too strict
- fieldalignment # Ignore "fieldalignment: struct with XXX pointer bytes could be YYY"
- "shadow: declaration of" # Relax govet
- "shadows an import name" # Relax revive
- "ifElseChain: rewrite if-else to switch statement" # IfElseChain actually preferred to switches
- "nested-structs: no nested structs are allowed" # Relax revive
- "confusing-naming" # Relax revive, we often use Foo and foo function names.
- "flag-parameter" # Relax revive, flag parameters are ok if used sparingly.
- "G306: Expect WriteFile permissions to be 0600 or less" # We write a lot of files that need to be editable.
- "exported: type name will be used as module.Module" # Cosmos style
# Loop variable issues have been fixed in Go 1.22, so can be ignored
- "G601: Implicit memory aliasing in for loop"
- "loopclosure: loop variable"
- "Range statement for test"
- "range-val-address: suspicious assignment of"
- "exporting a pointer for the loop variable snapshot"
linters:
enable-all: true
disable:
# Disable some linters (alphabetical order)
- cyclop # False positives, address in code reviews
- depguard # Dependency guard is for enterprise users
- exhaustruct # Exhaustive structs results in super verbose go code
- funlen # Some functions will be long
- gocognit # We tend to write long multi-step functions
- gochecknoglobals # We use globals in many places
- goerr113 # We do not religiously follow the Go 1.13 package level error convention
- godox # Allow TODOs
- goimports # Handled by gci
- gofumpt # Not compatible with gci, see https://github.com/golangci/golangci-lint/issues/1490.
- gomnd # Too many false positives
- gomoddirectives # We have a replace directive
- ireturn # Too many false positives
- prealloc # Too many false positives
- tagliatelle # Too strict
- varnamelen # False positives
- wsl # Way to strict and opinionated
- lll # Disable rigid line length limit
# Disable deprecated/archived linters (alphabetical order)
- deadcode
- exhaustivestruct
- golint
- ifshort
- interfacer
- maligned
- nosnakecase
- scopelint
- structcheck
- varcheck