Skip to content

Commit 82ffe2a

Browse files
committed
fix: use tagged switch instead of if-else (staticcheck QF1003)
Convert if-else chain to switch statement in TestFactorizationMachines_WeightedTraining for cleaner code.
1 parent 9f354f5 commit 82ffe2a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

model/ctr/model_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,11 @@ func TestFactorizationMachines_WeightedTraining(t *testing.T) {
271271
foundPurchase := false
272272
for i := 0; i < train.Count(); i++ {
273273
w := train.GetWeight(i)
274-
if train.FeedbackTypes[i] == "click" {
274+
switch train.FeedbackTypes[i] {
275+
case "click":
275276
assert.Equal(t, float32(1.0), w)
276277
foundClick = true
277-
} else if train.FeedbackTypes[i] == "purchase" {
278+
case "purchase":
278279
assert.Equal(t, float32(5.0), w)
279280
foundPurchase = true
280281
}

0 commit comments

Comments
 (0)