-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.golangci.yaml
132 lines (127 loc) · 7.08 KB
/
.golangci.yaml
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
# Output configuration options
output:
# Sort results by: filepath, line and column
sort-results: true
# Enabled/disabled linters
linters:
enable-all: true
disable:
- exhaustivestruct # Checks if all struct's fields are initialized
- forbidigo # Forbids identifiers
- gochecknoglobals # check that no global variables exist
- godot # Check if comments end in a period
- godox # Tool for detection of FIXMEs, TODOs and other comment keywords. TODO: Enable in stable version
- goerr113 # Golang linter to check the errors handling expressions
- golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
- interfacer # Linter that suggests narrower interface types
- ireturn # Accept Interfaces, Return Concrete Types
- maligned # Tool to detect Go structs that would take less memory if their fields were sorted
- nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity
- paralleltest # paralleltest detects missing usage of t.Parallel() method in your Go test
- scopelint # Scopelint checks for unpinned variables in go programs
- 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!
- gomnd # An analyzer to detect magic numbers.
# 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
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
deadcode: # Finds unused code
# Include test files
test: true
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.
local-prefixes: github.com/mymmrac/chipper
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
gocritic: # Provides diagnostics that check for bugs, performance and style issues.
# Which checks should be disabled; can't be combined with 'enabled-checks'.
disabled-checks:
- appendAssign
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