-
Notifications
You must be signed in to change notification settings - Fork 4
/
.golangci.yaml
125 lines (117 loc) · 4.07 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
# Reference: https://golangci-lint.run/usage/configuration/
run:
# timeout for analysis, e.g. 30s, 5m. Default: 1m
timeout: 5m
linters:
# Disable only specific linters. Since a specific version of golangci-lint is
# used in the CI, this should be reasonably stable. The checks should only
# "surprisingly" fail when the version is updated.
enable-all: true
disable:
- copyloopvar # Prefer the old style for now, it's more reliable across various scanners.
- depguard # No deps we need to guard against.
- exhaustruct # Too exhausting to initialize everything in many k8s objects.
- gochecknoinits # Init statements can be good.
- gochecksumtype # This would require using another tool to define sumtypes.
- gomoddirectives # Replace directives are necessary.
- gomodguard # No mods we need to guard against.
- interfacebloat # This is a job for a reviwer, not a linter.
- intrange # Too new of a language feature for now.
- nonamedreturns # Named returns can be good.
- nolintlint # Sometimes gives a false positive based on caching.
- testifylint # This package is not used in the tests.
- testpackage # The _test package is only sometimes helpful.
- wrapcheck # Always wrapping is overkill.
- wsl # Too opinionated; nlreturn and whitespace are sufficient.
# The following linters are deprecated.
- deadcode
- exhaustivestruct
- execinquery
- golint
- ifshort
- interfacer
- maligned
- gomnd
- nosnakecase
- scopelint
- structcheck
- varcheck
linters-settings:
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
check-type-assertions: true
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check. Default: 60
lines: 120
gci:
sections:
- standard
- default
- prefix(open-cluster-management.io)
gocritic:
enable-all: true
disabled-checks:
- hugeParam # Passing by value is helpful to imply no mutation.
goheader:
template: Copyright Contributors to the Open Cluster Management project
lll:
# Max line length, lines longer will be reported.
# '\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: 1
tab-width: 4
misspell:
# Correct spellings using locale preferences for US or UK.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
# Default is to use a neutral variety of English.
locale: US
ignore-words:
- cancelled
nakedret:
# Make an issue if func has more lines of code than this setting, and it has naked returns.
max-func-lines: 1
varnamelen:
max-distance: 15
ignore-decls:
- r client.Reader
- ok bool
issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude: []
exclude-rules:
# Allow dot imports in the tests.
- path: _test\.go
linters:
- revive
text: dot imports
# Don't enforce max line length for kubebuilder markers
- linters:
- lll
source: \/\/ ?\+kubebuilder
# Don't enforce max line length on comments that start with a URL
- linters:
- lll
source: \/\/ ?https?:\/\/
# Don't enforce some rules on test files
- path: _test\.go$
linters:
- varnamelen
- wsl
- ireturn
- gochecknoglobals
- dupl
- funlen
# main.go tends to have longer functions
- path: main.go
linters:
- funlen
- cyclop
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
# Fix found issues (if it's supported by the linter). Default: false
fix: false