This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.golangci
189 lines (182 loc) · 9.9 KB
/
.golangci
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
# 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:
- test
- generator
# Output configuration options
output:
# Sort results by: filepath, line and column
sort-results: true
# Enabled/disabled linters
linters:
disable-all: true
enable:
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- unused # Checks Go's code for unused constants, variables, functions and types
- gosimple # Linter for Go source code that specializes in simplifying a code
- structcheck # Finds unused struct fields
- varcheck # Finds unused global variables and constants
- ineffassign # Detects when assignments to existing variables are not used
- deadcode # Finds unused code
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- nestif # Reports deeply nested if statements
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
- goimports # Goimports does everything that gofmt does. Additionally, it checks unused imports
- misspell # Finds commonly misspelled English words in comments
- dupl # Tool for code clone detection
- lll # Reports long lines
- gocyclo # Computes and checks the cyclomatic complexity of functions
- gofmt # Gofmt checks whether code was gofmt-ed. By default, this tool runs with -s option to check for code simplification
- gosec # Inspects source code for security problems
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
- gochecknoinits # Checks that no init functions are present in Go code
- gocognit # Computes and checks the cognitive complexity of functions
- goconst # Finds repeated strings that could be replaced by a constant
- gomnd # An analyzer to detect magic numbers.
- nakedret # Finds naked returns in functions greater than a specified function length
- unparam # Reports unused function parameters
- depguard # Go linter that checks if package imports are in a list of acceptable packages
- whitespace # Tool for detection of leading and trailing whitespace
- unconvert # Remove unnecessary type conversions
- rowserrcheck # Checks whether Err of rows is checked successfully
- prealloc # Finds slice declarations that could potentially be pre-allocated
- gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.
# - godox # Tool for detection of FIXME, TODO and other comment keywords
- gocritic # The most opinionated Go source code linter
- funlen # Tool for detection of long functions
- gci # Gci control golang package import order and make it always deterministic.
- bodyclose # Checks whether HTTP response body is closed successfully
- exportloopref # Checks for pointers to enclosing loop variables
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- errorlint # Errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
# 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
check-shadowing: true # report about shadowed variables
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
composites: true # check for unkeyed composite literals
copylocks: true # check for locks erroneously passed by value
httpresponse: true # check for mistakes using HTTP responses
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
stdmethods: true # check signature of methods of well-known interfaces
structtag: true # check that struct field tags conform to reflect.StructTag.Get
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
unusedresult: true # check for unused results of calls to some functions
gocyclo:
# Minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 15
dupl: # Tool for code clone detection
# Tokens count to trigger issue, 150 by default
threshold: 150
misspell:
# 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
nestif:
# Minimal complexity of if statements to report, 5 by default
# 2 to prevent scary functions/method/etc with a ton of nested ifs
min-complexity: 5 # Sonarqube uses 5
dogsled:
# Checks assignments with too many blank identifiers; default is 2
# 1 to prevent such work of art: _, _, value := functionCall()
max-blank-identifiers: 2
errcheck:
# 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
# Specify a path to a file containing a list of functions to be excluded.
# exclude:
# to be added
gocognit:
# Minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 20
goconst:
# Minimal length of string constant, 3 by default
min-len: 3
# Minimal occurrences count to trigger, 3 by default
min-occurrences: 3
gofmt:
# Simplify code: gofmt with `-s` option, true by default
simplify: true
gomnd:
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:
# 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:
# 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
unparam:
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unused:
# Treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
deadcode:
# Include test files
test: true
staticcheck:
# Include tests in the analysis.
tests: true
depguard:
list-type: blacklist
include-go-root: false
packages:
- unsafe
- reflect
funlen:
lines: 150
statements: 50
gci:
local-prefixes: github.com/servusdei2018/protoncheck
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