Skip to content

Commit 0cde5f1

Browse files
mmorel-35pohly
andauthored
fix: enable bool-compare rule from testifylint linter (kubernetes#125135)
* fix: enable bool-compare rule from testifylint linter Signed-off-by: Matthieu MOREL <[email protected]> * Update hack/golangci.yaml.in Co-authored-by: Patrick Ohly <[email protected]> * Update golangci.yaml.in * Update golangci-strict.yaml * Update golangci.yaml.in * Update golangci.yaml.in * Update golangci.yaml.in * Update golangci.yaml.in * Update golangci.yaml * Update golangci-hints.yaml * Update golangci-strict.yaml * Update golangci.yaml.in * Update golangci.yaml * Update mux_test.go --------- Signed-off-by: Matthieu MOREL <[email protected]> Co-authored-by: Patrick Ohly <[email protected]>
1 parent bcadbfc commit 0cde5f1

File tree

16 files changed

+78
-41
lines changed

16 files changed

+78
-41
lines changed

hack/golangci-hints.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ linters:
9090
- revive
9191
- staticcheck
9292
- stylecheck
93+
- testifylint
9394
- unused
9495

9596
linters-settings: # please keep this alphabetized
@@ -179,3 +180,5 @@ linters-settings: # please keep this alphabetized
179180
staticcheck:
180181
checks:
181182
- "all"
183+
testifylint:
184+
enable-all: true

hack/golangci-strict.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ linters:
133133
- revive
134134
- staticcheck
135135
- stylecheck
136+
- testifylint
136137
- unused
137138
disable:
138139
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1507008359
@@ -219,3 +220,5 @@ linters-settings: # please keep this alphabetized
219220
staticcheck:
220221
checks:
221222
- "all"
223+
testifylint:
224+
enable-all: true

hack/golangci.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ linters:
139139
- revive
140140
- staticcheck
141141
- stylecheck
142+
- testifylint
142143
- unused
143144

144145
linters-settings: # please keep this alphabetized
@@ -231,3 +232,17 @@ linters-settings: # please keep this alphabetized
231232
stylecheck:
232233
checks:
233234
- "ST1019" # Importing the same package multiple times
235+
testifylint:
236+
enable-all: true
237+
disable: # TODO: remove each disabled rule and fix it
238+
- blank-import
239+
- compares
240+
- empty
241+
- error-is-as
242+
- error-nil
243+
- expected-actual
244+
- float-compare
245+
- go-require
246+
- len
247+
- nil-compare
248+
- require-error

hack/golangci.yaml.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ linters:
148148
- revive
149149
- staticcheck
150150
- stylecheck
151+
- testifylint
151152
- unused
152153
{{- if .Strict}}
153154
disable:
@@ -206,3 +207,19 @@ linters-settings: # please keep this alphabetized
206207
checks:
207208
- "ST1019" # Importing the same package multiple times
208209
{{- end}}
210+
testifylint:
211+
enable-all: true
212+
{{- if .Base}}
213+
disable: # TODO: remove each disabled rule and fix it
214+
- blank-import
215+
- compares
216+
- empty
217+
- error-is-as
218+
- error-nil
219+
- expected-actual
220+
- float-compare
221+
- go-require
222+
- len
223+
- nil-compare
224+
- require-error
225+
{{- end}}

pkg/controller/endpointslice/endpointslice_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ func TestPodDeleteBatching(t *testing.T) {
16851685

16861686
old, exists, err := esController.podStore.GetByKey(fmt.Sprintf("%s/%s", ns, update.podName))
16871687
assert.Nil(t, err, "error while retrieving old value of %q: %v", update.podName, err)
1688-
assert.Equal(t, true, exists, "pod should exist")
1688+
assert.True(t, exists, "pod should exist")
16891689
esController.podStore.Delete(old)
16901690
esController.deletePod(old)
16911691
}

pkg/kubelet/cm/dra/claiminfo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func TestClaimInfoSetPrepared(t *testing.T) {
488488
} {
489489
t.Run(test.description, func(t *testing.T) {
490490
test.claimInfo.setPrepared()
491-
assert.Equal(t, test.claimInfo.isPrepared(), true)
491+
assert.True(t, test.claimInfo.isPrepared())
492492
})
493493
}
494494
}

pkg/kubelet/container/helpers_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,21 +680,21 @@ func TestShouldRecordEvent(t *testing.T) {
680680
}
681681

682682
_, actual := innerEventRecorder.shouldRecordEvent(nil)
683-
assert.Equal(t, false, actual)
683+
assert.False(t, actual)
684684

685685
var obj = &v1.ObjectReference{Namespace: "claimrefns", Name: "claimrefname"}
686686

687687
_, actual = innerEventRecorder.shouldRecordEvent(obj)
688-
assert.Equal(t, true, actual)
688+
assert.True(t, actual)
689689

690690
obj = &v1.ObjectReference{Namespace: "system", Name: "infra", FieldPath: "implicitly required container "}
691691

692692
_, actual = innerEventRecorder.shouldRecordEvent(obj)
693-
assert.Equal(t, false, actual)
693+
assert.False(t, actual)
694694

695695
var nilObj *v1.ObjectReference = nil
696696
_, actual = innerEventRecorder.shouldRecordEvent(nilObj)
697-
assert.Equal(t, false, actual, "should not panic if the typed nil was used, see https://github.com/kubernetes/kubernetes/issues/95552")
697+
assert.False(t, actual, "should not panic if the typed nil was used, see https://github.com/kubernetes/kubernetes/issues/95552")
698698
}
699699

700700
func TestHasWindowsHostProcessContainer(t *testing.T) {

pkg/kubelet/kubelet_getters_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ func TestHandlerSupportsUserNamespaces(t *testing.T) {
121121
})
122122

123123
got, err := kubelet.HandlerSupportsUserNamespaces("has-support")
124-
assert.Equal(t, true, got)
124+
assert.True(t, got)
125125
assert.NoError(t, err)
126126

127127
got, err = kubelet.HandlerSupportsUserNamespaces("has-no-support")
128-
assert.Equal(t, false, got)
128+
assert.False(t, got)
129129
assert.NoError(t, err)
130130

131131
got, err = kubelet.HandlerSupportsUserNamespaces("unknown")
132-
assert.Equal(t, false, got)
132+
assert.False(t, got)
133133
assert.Error(t, err)
134134
}

pkg/kubelet/kubelet_node_status_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,8 +2732,7 @@ func TestRegisterWithApiServerWithTaint(t *testing.T) {
27322732
Effect: v1.TaintEffectNoSchedule,
27332733
}
27342734

2735-
require.Equal(t,
2736-
true,
2735+
require.True(t,
27372736
taintutil.TaintExists(got.Spec.Taints, unschedulableTaint),
27382737
"test unschedulable taint for TaintNodesByCondition")
27392738
}

pkg/kubelet/nodeshutdown/nodeshutdown_manager_linux_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ func TestManager(t *testing.T) {
364364
assert.NoError(t, err, "expected manager.Start() to not return error")
365365
assert.True(t, fakeDbus.didInhibitShutdown, "expected that manager inhibited shutdown")
366366
assert.NoError(t, manager.ShutdownStatus(), "expected that manager does not return error since shutdown is not active")
367-
assert.Equal(t, manager.Admit(nil).Admit, true)
367+
assert.True(t, manager.Admit(nil).Admit)
368368

369369
// Send fake shutdown event
370370
select {
@@ -386,7 +386,7 @@ func TestManager(t *testing.T) {
386386
}
387387

388388
assert.Error(t, manager.ShutdownStatus(), "expected that manager returns error since shutdown is active")
389-
assert.Equal(t, manager.Admit(nil).Admit, false)
389+
assert.False(t, manager.Admit(nil).Admit)
390390
assert.Equal(t, tc.expectedPodToGracePeriodOverride, killedPodsToGracePeriods)
391391
assert.Equal(t, tc.expectedDidOverrideInhibitDelay, fakeDbus.didOverrideInhibitDelay, "override system inhibit delay differs")
392392
if tc.expectedPodStatuses != nil {

0 commit comments

Comments
 (0)