Skip to content

Commit 21fa8d1

Browse files
committed
hack/tools enable additional linter in golangci-lint
Enables linter gocritic with two checks enabled for a subset of the project
1 parent e876d63 commit 21fa8d1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.golangci.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ issues:
77
max-same-issues: 0
88
# Excluding configuration per-path, per-linter, per-text and per-source
99
exclude-rules:
10-
# exclude ineffassing linter for generated files for conversion
10+
# exclude ineffassign linter for generated files for conversion
1111
- path: conversion\.go
1212
linters:
1313
- ineffassign
14+
# TODO(oscr) Remove these excluded directories and fix findings. Due to large amount of findings in different components
15+
# with different owners it's hard to fix everything in a single pr. This will therefore be done in multiple prs.
16+
- path: (pkg/volume/*|test/*|cmd/kubeadm/*|azure/*|pkg/cmd/wait*|request/bearertoken/*|metrics/*|filters/*)
17+
linters:
18+
- gocritic
1419

1520
linters:
1621
disable-all: true
1722
enable: # please keep this alphabetized
23+
- gocritic
1824
- ineffassign
1925
- logcheck
2026
- staticcheck
@@ -28,6 +34,10 @@ linters-settings: # please keep this alphabetized
2834
path: _output/local/bin/logcheck.so
2935
description: structured logging checker
3036
original-url: k8s.io/klog/hack/tools
37+
gocritic:
38+
enabled-checks:
39+
- equalFold
40+
- boolExprSimplify
3141
staticcheck:
3242
checks: [
3343
"all",

staging/src/k8s.io/cli-runtime/pkg/resource/scheme.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (dynamicCodec) Decode(data []byte, gvk *schema.GroupVersionKind, obj runtim
4141
return nil, nil, err
4242
}
4343

44-
if strings.ToLower(gvk.Kind) == "status" && gvk.Version == "v1" && (gvk.Group == "" || gvk.Group == "meta.k8s.io") {
44+
if strings.EqualFold(gvk.Kind, "status") && gvk.Version == "v1" && (gvk.Group == "" || gvk.Group == "meta.k8s.io") {
4545
if _, ok := obj.(*metav1.Status); !ok {
4646
obj = &metav1.Status{}
4747
err := json.Unmarshal(data, obj)

0 commit comments

Comments
 (0)