-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy path.golangci.yml
131 lines (126 loc) · 4.48 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
run:
deadline: 10m
linters-settings:
gocyclo:
min-complexity: 30
lll:
line-length: 180
gci:
sections:
- standard
- default
- prefix(github.com/opendatahub-io/opendatahub-operator)
- blank
- dot
skip-generated: false
custom-order: true
goconst:
ignore-strings: "true|false"
errcheck:
check-type-assertions: true
exhaustive:
check:
- switch
default-signifies-exhaustive: true
funlen:
lines: 100
statements: 100
ignore-comments: true
nolintlint:
allow-no-explanation: [ funlen, lll ]
require-specific: true
importas:
alias:
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1
alias: dsciv1
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1
alias: dscv1
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1
alias: infrav1
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1
alias: componentApi
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/apis/services/v1alpha1
alias: serviceApi
- pkg: k8s.io/apimachinery/pkg/api/errors
alias: k8serr
# Ensures that i.e. k8s.io/api/rbac/v1 is aliased as rbacv1
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
alias: $1$2
- pkg: github.com/openshift/api/(\w+)/(v[\w\d]+)
alias: $1$2
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/controllers/datasciencecluster
alias: dscctrl
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/controllers/dscinitialization
alias: dscictrl
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/controllers/components/(\w+)
alias: ${1}ctrl
- pkg: github.com/opendatahub-io/opendatahub-operator/v2/controllers/services/(\w+)
alias: ${1}ctrl
ireturn:
allow:
# defaults https://golangci-lint.run/usage/linters/#ireturn
- anon
- error
- empty
- stdlib
# also allow generics
- generic
- EventHandler # for ToOwner
- discovery.DiscoveryInterface
- dynamic.Interface
- predicate.Predicate
- client.Object
- common.PlatformObject
- types.AsyncAssertion
- kubernetes.Interface
revive:
rules:
- name: dot-imports
arguments:
- allowedPackages: ["github.com/onsi/ginkgo/v2","github.com/onsi/gomega","github.com/onsi/gomega/gstruct"]
perfsprint:
sprintf1: false
strconcat: false
# Enable gocritic for detecting bugs, performance, and style issues: https://golangci-lint.run/usage/linters/#gocritic
gocritic:
# https://go-critic.com/overview.html#checkers
enabled-checks:
- deferInLoop
- unnecessaryDefer
linters:
enable-all: true
disable:
- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages
- exhaustruct # Prevents empty struct. We use a lot of these so I think it is safe to disable.c
- forbidigo
- gochecknoglobals # Prevents use of global vars.
- gofumpt
- gomoddirectives # Doesnot allow replace in go mod file
- mnd
- nestif
- nilnil
- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
- tagliatelle
- varnamelen # doesnot allow shorter names like c,k etc. But golang prefers short named vars.
- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
- wrapcheck # check if this is required. Prevents direct return of err.
- exportloopref # Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar.
# Need to check
- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
- err113 # [too strict] checks the errors handling expressions
# To be fixed
- gocognit # https://github.com/opendatahub-io/opendatahub-operator/issues/709
- cyclop # https://github.com/opendatahub-io/opendatahub-operator/issues/709
- funlen # https://github.com/opendatahub-io/opendatahub-operator/issues/709
- godox # https://github.com/opendatahub-io/opendatahub-operator/issues/699
issues:
exclude-dirs:
- apis
exclude-rules:
- path: tests/*/(.+)_test\.go
linters:
- typecheck
- dupl
- path: pkg/utils/test/testf/(.+)\.go
linters:
- containedctx