-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy path.golangci.yml
204 lines (192 loc) · 8.49 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
# 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
- cyclop # Checks function and package cyclomatic complexity
- containedctx # containedctx is a linter that detects struct contained context.Context field
- depguard # Go linter that checks if package imports are in a list of acceptable packages
- dupword # checks for duplicate words in the source code
- dupl # Tool for code clone detection
- exhaustruct # Checks if all structure fields are initialized
- gochecknoglobals # check that no global variables exist
- godot # Check if comments end in a period
- err113 # Golang linter to check the errors handling expressions
- ireturn # Accept Interfaces, Return Concrete Types
- intrange # Intrange is a linter to find places where for loops could make use of an integer range
- 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 deprecated
- tenv # Tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
# 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
# Enable all analyzers.
# Default: false
enable-all: true
# Disable analyzers by name.
# Run `go tool vet help` to see all analyzers.
# Default: []
disable:
- fieldalignment # check for struct field alignments
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
mnd: # An analyzer to detect magic numbers.
# 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
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
disabled: true # Duplicate: gocognit
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#comment-spacings
- name: comment-spacings
severity: warning
disabled: false
arguments:
- nolint
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic
- name: cyclomatic
disabled: true # Duplicate: gocyclo
# 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
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 "
# Exclude liters for test files
- path: "_test\\.go$"
linters:
- funlen
- maintidx
- revive
# Exclude linters for types file
- path: "types.go"
linters:
- funlen
# Exclude linters for methods file
- path: "methods.go"
linters:
- lll
# Which dirs to exclude: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path,
# including the path prefix if one is set.
# Default dirs are skipped independently of this option's value (see exclude-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work on Windows.
# Default: []
exclude-dirs:
- mock
- internal
# 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