-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.golangci.yml
141 lines (122 loc) · 5.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
---
# options for analysis running
run:
deadline: 300s
tests: true
skip-dirs:
skip-files:
- ".*\\.pb\\.go"
- ".*_test\\.go"
- ".*_gen\\.go"
- "syncmap.go"
silent: true
# output configuration options
output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
# all available settings of specific linters
linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
govet:
check-shadowing: true
gofmt:
simplify: true
goconst:
min-len: 3
min-occurrences: 3
misspell:
locale: UK
unused:
check-exported: false
nakedret:
max-func-lines: 30
prealloc:
simple: true
range-loops: true
for-loops: true
goimports:
local-prefixes: gitlab.alipay-inc.com/sofagw/sofagw
lll:
line-length: 120
tab-width: 1
gocyclo:
min-complexity: 24
linters:
enable:
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes [fast: true]
- misspell # Finds commonly misspelled English words in comments [fast: true]
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true]
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false]
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false]
- unused # Checks Go code for unused constants, variables, functions and types [fast: false]
- gas # Inspects source code for security problems [fast: false]
- structcheck # Finds an unused struct fields [fast: false]
- interfacer # Linter that suggests narrower interface types [fast: false]
- unconvert # Remove unnecessary type conversions [fast: false]
- prealloc # Finds slicex declarations that could potentially be preallocated [fast: true]
- goimports # Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true]
- lll # Reports long lines [fast: true]
disable:
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true]
- dupl # Tool for code clone detection [fast: true]
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false]
- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: false]
- varcheck # Finds unused global variables and constants [fast: false]
- deadcode # Finds unused code [fast: false]
- gosimple # Linter for Go source code that specializes in simplifying a code [fast: false]
- goconst # Finds repeated strings that could be replaced by a constant [fast: true]
- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true]
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted [fast: false]
- megacheck # 3 sub-linters in one: unused, gosimple and staticcheck [fast: false]
issues:
exclude-use-default: false
exclude:
- "`clas` is a misspelling of `class`"
- "`color` is a misspelling of `colour`"
- "exported .* should have comment"
# unparam
- \(error\) is always nil
- "File is not `goimports`-ed"
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of
.((os\.)?std(out|err)\..*|mr.Register|.*prometheus.Registry\).Register|.*.Encode|rw.Write|.*encoding/json.Encoder|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv).
is not checked
# golint: Exported variables are rarely used and generally reserved for errors which should be self explanitory
- exported var \w+ should have comment or be unexported
# golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that
stutters; consider calling this
# gas: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# gas: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# gas: Duplicated errcheck checks
- G104
# gas: Look for bad TLS connection settings
- G402
# gas: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file
permissions to be 0600 or less)
# gas: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
# govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# megacheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- ineffective break statement. Did you mean to break out of the outer
loop
# mispell:
- synchronized
- serialize
- minimize
- initialized
- Unauthorized
- center
- behavior
- Fulfill
- serialization
- optimize
# structcheck
- "`noCopy` is unused"