-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yml
161 lines (147 loc) · 4.18 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
159
160
161
linters-settings:
asasalint: # will prevent any function for having "...any" variadic parameter except log funcs
exclude:
- \.Debugf
- \.Infof
- \.Warnf
- \.Errorf
- \.Fatalf
ignore-test: true
errcheck:
check-type-assertions: true
gocyclo:
min-complexity: 10
dupl:
threshold: 200
goconst:
min-len: 2
min-occurrences: 3
ignore-tests: true
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
settings:
hugeParam:
sizeThreshold: 500 # set a size threshold for heavy struct to force developers use pointers instead of passing params by value
gomnd:
checks:
- argument
- case
- condition
- operation
- return
- assign
ignored-numbers:
- "0"
- "1"
- "2"
- "3"
- '0666' # will ignore hard coded numbers which are permission codes, but a better approach is using octal number e.g: 0o666 and remove this section
- '0755'
ignored-functions:
- '^math\.' # will ignore hard coded numbers which are used alongside math, e.g: math.rand() * 2
- '^context\.' # will ignore hard coded numbers which are used alongside context, e.g: context.WithTimeout(context.Background(), 3*time.Second)
govet:
check-shadowing: true
enable:
- fieldalignment
- nilfunc
- nilness
revive:
severity: error
enable-all-rules: true
confidence: 0.8
rules:
- name: unused-parameter
severity: warning
disabled: false
# arguments:
# - allowRegex: "." # use regex to allow an unused-parameter when you need, e.g: (tx *gorm.DB) in gorm hooks
- name: unused-receiver
severity: warning
disabled: false
# arguments:
# - allowRegex: "." # use regex to allow an unused-receiver when you need
- name: line-length-limit # will check for line length but you have to enable it
severity: warning
disabled: true
arguments: [80] # pass a desired number for each line length restriction
- name: unchecked-type-assertion
severity: warning
disabled: true
- name: add-constant
severity: warning
disabled: false
arguments:
- maxLitCount: "10"
allowStrs: '""'
allowInts: "0,1,2,3,4"
- name: cognitive-complexity # will check for code complexity and every if, else, ||, & and ! charactars will add to complexity score
severity: warning
disabled: true
arguments: [10] # pass a desired number for complexity score, smaller numbers means more restrictions for using if, else, ||, & and ! chars
- name: max-public-structs # set a max number for restricting max public struct count in a file
severity: warning
disabled: false
arguments: [10]
nolintlint:
require-explanation: true
require-specific: true
depguard: # will check dependencies and imported packages with defined rules
rules:
main:
files:
- "!**/*_a _file.go"
allow:
- $gostd
- github.com/rezakhdemix
- github.com/redis
deny:
- pkg: "github.com/pkg/example"
desc: should be replaced by blah blah package
linters:
disable-all: true
enable:
- asasalint
- cyclop
# - depguard # if enabled, will check dependencies and imported packages with defined rules
- dupl
- errcheck
# - errorlint # if enabled, will check for wrapping errors and error type assertions without ,ok idioms
- exhaustive
- goconst
- gocritic
# - godox # if enabled, will check lines for finding "todos", "bug" and "fixme" pharses
- gocyclo
- gomnd
- gosimple
- gosec
- govet
- misspell
- musttag
- perfsprint
- prealloc
- predeclared
- usestdlibvars
- whitespace
- wsl
- revive
- bodyclose
- exportloopref
- ineffassign
- nolintlint
- stylecheck
- unconvert
run:
issues-exit-code: 1
issues:
exclude-rules:
- path: _test\.go
linters:
- gocyclo
- gosec
- dupl