forked from mymmrac/telego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yml
231 lines (221 loc) · 10.8 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# Options for analysis running
run:
# Which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- mock
- internal
# Output configuration options
output:
# Sort results by: filepath, line and column
sort-results: true
# Enabled/disabled linters
linters:
enable-all: true
disable:
# Disabled because not relevant for this project
- dupword # checks for duplicate words in the source code
- exhaustruct # Checks if all structure fields are initialized
- gochecknoglobals # check that no global variables exist
- godot # Check if comments end in a period
- goerr113 # Golang linter to check the errors handling expressions
- ireturn # Accept Interfaces, Return Concrete Types
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
- noctx # noctx finds sending http request without context.Context
- nonamedreturns # Reports all named returns
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
- tagliatelle # Checks the struct tags
- testpackage # linter that makes you use a separate _test package
- varnamelen # checks that the length of a variable's name matches its scope
- wrapcheck # Checks that errors returned from external packages are wrapped
- wsl # Whitespace Linter - Forces you to use empty lines!
# Disabled because of generics
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed
- wastedassign # wastedassign finds wasted assignment statements
# Disabled because deprecated
- deadcode # Finds unused code
- exhaustivestruct # Checks if all struct's fields are initialized
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
- ifshort # Checks that your code uses short syntax for if-statements whenever possible
- interfacer # Linter that suggests narrower interface types
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted
- nosnakecase # nosnakecase is a linter that detects snake case of variable naming and function name.
- scopelint # Scopelint checks for unpinned variables in go programs
- structcheck # Finds unused struct fields
- varcheck # Finds unused global variables and constants
# To see a list of enabled/disabled by current configuration linters:
# golangci-lint linters
# Settings of specific linters
linters-settings:
govet: # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not
# align with the format string
asmdecl: true # report mismatches between assembly files and Go declarations
assign: true # check for useless assignments
atomic: true # check for common mistakes using the sync/atomic package
bools: true # check for common mistakes involving boolean operators
buildtag: true # check that +build tags are well-formed and correctly located
cgocall: true # detect some violations of the cgo pointer passing rules
composites: true # check for unkeyed composite literals
copylocks: true # check for locks erroneously passed by value
errorsas: true # report passing non-pointer or non-error values to errors.As
framepointer: true # report assembly that clobbers the frame pointer before saving it
httpresponse: true # check for mistakes using HTTP responses
ifaceassert: true # detect impossible interface-to-interface type assertions
loopclosure: true # check references to loop variables from within nested functions
lostcancel: true # check cancel func returned by context.WithCancel is called
nilfunc: true # check for useless comparisons between functions and nil
printf: true # check consistency of Printf format strings and arguments
shift: true # check for shifts that equal or exceed the width of the integer
sigchanyzer: true # check for unbuffered channel of os.Signal
stdmethods: true # check signature of methods of well-known interfaces
stringintconv: true # check for string(int) conversions
structtag: true # check that struct field tags conform to reflect.StructTag.Get
testinggoroutine: true # report calls to (*testing.T).Fatal from goroutines started by a test.
tests: true # check for common mistaken usages of tests and examples
unmarshal: true # report passing non-pointer or non-interface values to unmarshal
unreachable: true # check for unreachable code
unsafeptr: true # check for invalid conversions of uintptr to unsafe.Pointer
unusedresult: true # check for unused results of calls to some functions
gocyclo: # Computes and checks the cyclomatic complexity of functions
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 15
misspell: # Finds commonly misspelled English words in comments
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
errcheck: # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be
# critical bugs in some cases.
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: true
gocognit: # Computes and checks the cognitive complexity of functions
# Minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 20
gomnd: # An analyzer to detect magic numbers.
settings:
mnd:
# The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks:
- argument
- assign
- case
- condition
- operation
- return
lll: # Reports long lines
# Max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 120
# Tab width in spaces. Default to 1.
# tabulation - 4 spaces. the end.
tab-width: 4
nakedret: # Finds naked returns in functions greater than a specified function length
# Make an issue if func has more lines of code than this setting, and it has naked returns; default is 30
# decided to use 3 to exclude long functions with named returns which can be a potential source of many errors / bugs
max-func-lines: 3
staticcheck: # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
# Include tests in the analysis.
tests: true
depguard: # Go linter that checks if package imports are in a list of acceptable packages
list-type: blacklist
include-go-root: false
packages:
- unsafe
- reflect
funlen: # Tool for detection of long functions
lines: 120
statements: 40
gci: # Gci control golang package import order and make it always deterministic.
sections:
- standard
- default
- prefix(github.com/mymmrac/telego)
exhaustive: # check exhaustiveness of enum switch statements
# Presence of "default" case in switch statements satisfies exhaustiveness,
# even if all enum members are not listed
default-signifies-exhaustive: true
revive:
# Enable all available rules.
# Default: false
enable-all-rules: true
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant
- name: add-constant
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit
- name: argument-limit
severity: warning
disabled: false
arguments: [ 7 ]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters
- name: banned-characters
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity
- name: cognitive-complexity
severity: warning
disabled: false
arguments: [ 20 ]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic
- name: cyclomatic
severity: warning
disabled: false
arguments: [ 15 ]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header
- name: file-header
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit
- name: function-result-limit
severity: warning
disabled: false
arguments: [ 3 ]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length
- name: function-length
disabled: true # Duplicate: funlen
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit
- name: line-length-limit
disabled: true # Duplicate: lll
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs
- name: max-public-structs
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-value-receiver
- name: modifies-value-receiver
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
- name: package-comments
disabled: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
disabled: true
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 15
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude lll issues for long lines with go:generate
- linters:
- lll
source: "^//go:generate "
# Independently of option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
# Default value for this option is true.
exclude-use-default: false
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter: 0
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 0