Skip to content

Commit 6b6c098

Browse files
committed
Updates for golangci-lint
Switch config to be more consistent with other O-F repos. Fix lint issues. Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>
1 parent b51f67c commit 6b6c098

File tree

14 files changed

+202
-152
lines changed

14 files changed

+202
-152
lines changed

.golangci.yml

Lines changed: 74 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,77 @@
1-
issues:
2-
# don't skip warning about doc comments
3-
# don't exclude the default set of lint
4-
exclude-use-default: false
5-
# restore some of the defaults
6-
# (fill in the rest as needed)
7-
exclude-rules:
8-
- linters: [errcheck]
9-
text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
1+
run:
2+
# Default timeout is 1m, up to give more room
3+
timeout: 4m
4+
105
linters:
11-
disable-all: true
126
enable:
13-
- nakedret
14-
- interfacer
15-
- varcheck
16-
- deadcode
17-
- structcheck
18-
- misspell
19-
- maligned
20-
- ineffassign
21-
- goconst
22-
- goimports
23-
- errcheck
24-
- unparam
25-
- golint
26-
- staticcheck
27-
- gosimple
28-
- unused
29-
- govet
30-
- typecheck
31-
- gocyclo
32-
- gofmt
33-
- dupl
7+
- asciicheck
8+
- bodyclose
9+
- errorlint
10+
- gofmt
11+
- goimports
12+
- gosec
13+
- importas
14+
- misspell
15+
- nestif
16+
- nonamedreturns
17+
- prealloc
18+
- revive
19+
- stylecheck
20+
- tparallel
21+
- unconvert
22+
- unparam
23+
- unused
24+
- whitespace
3425

35-
run:
36-
deadline: 5m
26+
linters-settings:
27+
errorlint:
28+
errorf: false
29+
30+
importas:
31+
alias:
32+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
33+
alias: metav1
34+
- pkg: k8s.io/apimachinery/pkg/api/errors
35+
alias: apierrors
36+
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
37+
alias: apiextensionsv1
38+
- pkg: k8s.io/apimachinery/pkg/util/runtime
39+
alias: utilruntime
40+
- pkg: "^k8s\\.io/api/([^/]+)/(v[^/]+)$"
41+
alias: $1$2
42+
- pkg: sigs.k8s.io/controller-runtime
43+
alias: ctrl
44+
45+
goimports:
46+
#local-prefixes: github.com/operator-framework/operator-lib
47+
48+
revive:
49+
ignore-generated-header: false
50+
severity: warning
51+
confidence: 0.8
52+
rules:
53+
- name: blank-imports
54+
- name: context-as-argument
55+
- name: context-keys-type
56+
- name: error-return
57+
- name: error-strings
58+
- name: error-naming
59+
- name: exported
60+
- name: increment-decrement
61+
- name: var-naming
62+
- name: var-declaration
63+
- name: package-comments
64+
- name: range
65+
- name: receiver-naming
66+
- name: time-naming
67+
- name: unexported-return
68+
- name: indent-error-flow
69+
- name: errorf
70+
- name: empty-block
71+
- name: superfluous-else
72+
- name: unused-parameter
73+
- name: unreachable-code
74+
- name: redefines-builtin-id
75+
76+
output:
77+
format: tab

handler/enqueue_annotation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func SetOwnerAnnotations(owner, object client.Object) error {
164164
ownerGK := owner.GetObjectKind().GroupVersionKind().GroupKind()
165165

166166
if ownerGK.Kind == "" {
167-
return fmt.Errorf("Owner %s Kind not found, cannot call SetOwnerAnnotations", owner.GetName())
167+
return fmt.Errorf("owner %s Kind not found, cannot call SetOwnerAnnotations", owner.GetName())
168168
}
169169

170170
annotations := object.GetAnnotations()

handler/example_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ import (
1818
"context"
1919
"os"
2020

21-
"github.com/operator-framework/operator-lib/handler"
22-
v1 "k8s.io/api/core/v1"
21+
corev1 "k8s.io/api/core/v1"
2322
"sigs.k8s.io/controller-runtime/pkg/client/config"
2423
"sigs.k8s.io/controller-runtime/pkg/controller"
2524
"sigs.k8s.io/controller-runtime/pkg/manager"
2625
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
2726
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2827
"sigs.k8s.io/controller-runtime/pkg/source"
28+
29+
"github.com/operator-framework/operator-lib/handler"
2930
)
3031

3132
// This example applies the Pause handler to all incoming Pod events on a Pod controller.
@@ -54,7 +55,7 @@ func ExampleNewPause() {
5455
if err != nil {
5556
os.Exit(1)
5657
}
57-
if err := c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), pause); err != nil {
58+
if err := c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), pause); err != nil {
5859
os.Exit(1)
5960
}
6061

0 commit comments

Comments
 (0)