diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go index 80774aafd4..61fe1f5579 100644 --- a/pkg/trait/cron.go +++ b/pkg/trait/cron.go @@ -73,7 +73,7 @@ type cronInfo struct { type cronExtractor func(string) *cronInfo const ( - genericCronComponent = "cron" + genericCronComponent = "cron" genericCronComponentFallback = "camel:quartz" ) @@ -339,6 +339,7 @@ func getCronForURI(camelURI string) *cronInfo { // Specific extractors // timerToCronInfo converts a timer endpoint to a Kubernetes cron schedule +// nolint: gocritic func timerToCronInfo(camelURI string) *cronInfo { if uri.GetQueryParameter(camelURI, "delay") != "" || uri.GetQueryParameter(camelURI, "repeatCount") != "" || diff --git a/pkg/trait/cron_test.go b/pkg/trait/cron_test.go index 908d94a270..f36791b24b 100644 --- a/pkg/trait/cron_test.go +++ b/pkg/trait/cron_test.go @@ -183,8 +183,9 @@ func TestCronFromURI(t *testing.T) { } for _, test := range tests { - t.Run(test.uri, func(t *testing.T) { - uris := []string{test.uri, test.uri2, test.uri3} + thetest := test + t.Run(thetest.uri, func(t *testing.T) { + uris := []string{thetest.uri, thetest.uri2, thetest.uri3} filtered := make([]string, 0, len(uris)) for _, uri := range uris { if uri != "" { @@ -197,13 +198,13 @@ func TestCronFromURI(t *testing.T) { if res != nil { gotCron = res.schedule } - assert.Equal(t, gotCron, test.cron) + assert.Equal(t, gotCron, thetest.cron) gotComponents := "" if res != nil { gotComponents = strings.Join(res.components, ",") } - assert.Equal(t, gotComponents, test.components) + assert.Equal(t, gotComponents, thetest.components) }) } } diff --git a/pkg/util/knative/uri.go b/pkg/util/knative/uri.go index 905a842c84..6536818472 100644 --- a/pkg/util/knative/uri.go +++ b/pkg/util/knative/uri.go @@ -28,7 +28,6 @@ import ( var uriRegexp = regexp.MustCompile(`^knative:[/]*(channel|endpoint|event)/([A-Za-z0-9.-]+)(?:[/?].*|$)`) var plainNameRegexp = regexp.MustCompile(`^[A-Za-z0-9.-]+$`) -var queryExtractorRegexp = `^[^?]+\?(?:|.*[&])%s=([^&]+)(?:[&].*|$)` const ( paramAPIVersion = "apiVersion" diff --git a/pkg/util/uri/uri_test.go b/pkg/util/uri/uri_test.go index 049a53dcb3..18115cf385 100644 --- a/pkg/util/uri/uri_test.go +++ b/pkg/util/uri/uri_test.go @@ -81,9 +81,10 @@ func TestQueryParameter(t *testing.T) { } for _, test := range tests { - t.Run(test.uri, func(t *testing.T) { - param := GetQueryParameter(test.uri, test.param) - assert.Equal(t, test.expected, param) + thetest := test + t.Run(thetest.uri, func(t *testing.T) { + param := GetQueryParameter(thetest.uri, thetest.param) + assert.Equal(t, thetest.expected, param) }) }