Skip to content

Commit 7ffcef5

Browse files
committed
fix for linters and use b.Loop in benchmarks
1 parent 3c6b05e commit 7ffcef5

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

compiler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func BenchmarkCompile(b *testing.B) {
349349
if err != nil {
350350
b.Fatal(err)
351351
}
352-
for range b.N {
352+
for b.Loop() {
353353
_, err := gojq.Compile(
354354
query,
355355
gojq.WithInputIter(gojq.NewIter()),

option_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ func TestWithFunctionMultipleArities(t *testing.T) {
482482
}
483483
return fmt.Errorf("f cannot be applied to: %v, %v", x, xs)
484484
}),
485-
gojq.WithFunction("g", 0, 30, func(x any, xs []any) any {
485+
gojq.WithFunction("g", 0, 30, func(any, []any) any {
486486
return nil
487487
}),
488488
}
@@ -555,7 +555,7 @@ func TestWithFunctionValueError(t *testing.T) {
555555
t.Fatal(err)
556556
}
557557
code, err := gojq.Compile(query,
558-
gojq.WithFunction("f", 0, 0, func(x any, _ []any) any {
558+
gojq.WithFunction("f", 0, 0, func(any, []any) any {
559559
return &valueError{expected}
560560
}),
561561
)

query_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ func TestQueryRun_HaltError(t *testing.T) {
132132
t.Errorf("expected: %v, got: %v", expected, err)
133133
}
134134
break
135-
} else {
136-
t.Errorf("should emit a halt error but got: %v", err)
137135
}
136+
t.Errorf("should emit a halt error but got: %v", err)
138137
} else {
139138
t.Errorf("should emit an error but got: %v", v)
140139
}
@@ -377,7 +376,7 @@ func BenchmarkRun(b *testing.B) {
377376
if err != nil {
378377
b.Fatal(err)
379378
}
380-
for range b.N {
379+
for b.Loop() {
381380
iter := query.Run(nil)
382381
for {
383382
_, ok := iter.Next()
@@ -394,7 +393,7 @@ func BenchmarkParse(b *testing.B) {
394393
b.Fatal(err)
395394
}
396395
src := string(cnt)
397-
for range b.N {
396+
for b.Loop() {
398397
_, err := gojq.Parse(src)
399398
if err != nil {
400399
b.Fatal(err)

0 commit comments

Comments
 (0)