From d13ba98d1a5c028184e5b8ad48d4c4cae5a29cb2 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 18 May 2022 13:18:29 -0400 Subject: [PATCH] Fix a few small linting bugs (#17695) --- sdks/go/cmd/specialize/main.go | 6 +++--- sdks/go/pkg/beam/core/graph/coder/coder_fuzz_test.go | 2 +- sdks/go/pkg/beam/core/graph/mtime/time_test.go | 2 +- sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange.go | 2 ++ sdks/go/pkg/beam/pardo_test.go | 2 +- sdks/go/test/integration/primitives/checkpointing.go | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sdks/go/cmd/specialize/main.go b/sdks/go/cmd/specialize/main.go index fe45ab9fef16..2dfad62f68c4 100644 --- a/sdks/go/cmd/specialize/main.go +++ b/sdks/go/cmd/specialize/main.go @@ -306,17 +306,17 @@ func genericTypingRepresentation(in int, out int, includeType bool) string { func possibleBundleLifecycleParameterCombos(numInInterface interface{}, processElementInInterface interface{}) [][]string { numIn := numInInterface.(int) processElementIn := processElementInInterface.(int) - ordered_known_parameter_options := []string{"context.Context", "typex.PaneInfo", "[]typex.Window", "typex.EventTime", "typex.BundleFinalization"} + orderedKnownParameterOptions := []string{"context.Context", "typex.PaneInfo", "[]typex.Window", "typex.EventTime", "typex.BundleFinalization"} // Because of how Bundle lifecycle functions are invoked, all known parameters must precede unknown options and be in order. // Once we hit an unknown options, all remaining unknown options must be included since all iters/emitters must be included // Therefore, we can generate a powerset of the known options and fill out any remaining parameters with an ordered set of remaining unknown options - pSetSize := int(math.Pow(2, float64(len(ordered_known_parameter_options)))) + pSetSize := int(math.Pow(2, float64(len(orderedKnownParameterOptions)))) combos := make([][]string, 0, pSetSize) for index := 0; index < pSetSize; index++ { var subSet []string - for j, elem := range ordered_known_parameter_options { + for j, elem := range orderedKnownParameterOptions { // And with the bit representation to get this iteration of the powerset. if index&(1< 0 { subSet = append(subSet, elem) diff --git a/sdks/go/pkg/beam/core/graph/coder/coder_fuzz_test.go b/sdks/go/pkg/beam/core/graph/coder/coder_fuzz_test.go index 11c516f73782..f0436cd5506d 100644 --- a/sdks/go/pkg/beam/core/graph/coder/coder_fuzz_test.go +++ b/sdks/go/pkg/beam/core/graph/coder/coder_fuzz_test.go @@ -57,7 +57,7 @@ func FuzzEncodeDecodeDouble(f *testing.F) { actual, err := DecodeDouble(&buf) if err != nil { - t.Fatalf("DecodeDouble(%v) failed: %v", buf, err) + t.Fatalf("DecodeDouble(%v) failed: %v", &buf, err) } if math.Abs(actual-a) > floatPrecision { t.Fatalf("got %f, want %f +/- %f", actual, a, floatPrecision) diff --git a/sdks/go/pkg/beam/core/graph/mtime/time_test.go b/sdks/go/pkg/beam/core/graph/mtime/time_test.go index 26e2289172dd..951bd3360447 100644 --- a/sdks/go/pkg/beam/core/graph/mtime/time_test.go +++ b/sdks/go/pkg/beam/core/graph/mtime/time_test.go @@ -238,7 +238,7 @@ func TestToTime(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - if got, want := test.input.ToTime(), test.expOut; got != want { + if got, want := test.input.ToTime(), test.expOut; !got.Equal(want) { t.Errorf("ToTime(%v), got %v, want %v", test.input, got, want) } }) diff --git a/sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange.go b/sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange.go index 743891e80553..cd3ea3f9faa3 100644 --- a/sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange.go +++ b/sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange.go @@ -218,6 +218,8 @@ func (tracker *Tracker) GetRestriction() interface{} { return tracker.rest } +// IsBounded returns whether or not the restriction tracker is tracking a bounded restriction +// that has a set maximum value or an unbounded one which can grow indefinitely. func (tracker *Tracker) IsBounded() bool { return true } diff --git a/sdks/go/pkg/beam/pardo_test.go b/sdks/go/pkg/beam/pardo_test.go index b15cecbf5a1f..48c2b2adbecf 100644 --- a/sdks/go/pkg/beam/pardo_test.go +++ b/sdks/go/pkg/beam/pardo_test.go @@ -140,7 +140,7 @@ func (fn *AnnotationsFn) ProcessElement(v int) int { } func doNothing(_ []byte, _ int) {} -func TestParDoSideInputValdiation(t *testing.T) { +func TestParDoSideInputValidation(t *testing.T) { var tests = []struct { name string wFn *window.Fn diff --git a/sdks/go/test/integration/primitives/checkpointing.go b/sdks/go/test/integration/primitives/checkpointing.go index 6da0610c4976..f26b9f392acd 100644 --- a/sdks/go/test/integration/primitives/checkpointing.go +++ b/sdks/go/test/integration/primitives/checkpointing.go @@ -72,7 +72,7 @@ func (fn *selfCheckpointingDoFn) ProcessElement(rt *sdf.LockRTracker, _ []byte, if rt.TryClaim(position) { // Successful claim, emit the value and move on. emit(position) - position += 1 + position++ return sdf.ResumeProcessingIn(1 * time.Second) } else if rt.GetError() != nil || rt.IsDone() { // Stop processing on error or completion