From df4b0a79f52e74ee4ffe9226e7fe824a85d0e605 Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Thu, 3 Oct 2024 17:29:58 +0200 Subject: [PATCH] Fix linter issues --- cmd/cmd_helpers_test.go | 2 +- cmd/plugin_scaffold_test.go | 2 +- config/constants.go | 2 +- network/roundrobin_test.go | 2 +- network/server.go | 2 +- plugin/plugin_registry.go | 3 ++- plugin/plugin_registry_test.go | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/cmd_helpers_test.go b/cmd/cmd_helpers_test.go index f5fc15dc..a3fbc0ac 100644 --- a/cmd/cmd_helpers_test.go +++ b/cmd/cmd_helpers_test.go @@ -50,5 +50,5 @@ func mustPullPlugin() (string, error) { func runCommand(dir string, command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Dir = dir - return cmd.Run() + return cmd.Run() //nolint:wrapcheck } diff --git a/cmd/plugin_scaffold_test.go b/cmd/plugin_scaffold_test.go index d3c5f6c7..1c6d9bfd 100644 --- a/cmd/plugin_scaffold_test.go +++ b/cmd/plugin_scaffold_test.go @@ -53,7 +53,7 @@ func Test_pluginScaffoldCmd(t *testing.T) { err = runCommand(pluginDir, "go", "mod", "tidy") require.NoError(t, err, "running go mod tidy should not return an error") - runCommand(pluginDir, "make", "build-dev") + err = runCommand(pluginDir, "make", "build-dev") require.NoError(t, err, "running make build-dev should not return an error") pluginBinaryPath := filepath.Join(pluginDir, pluginName) diff --git a/config/constants.go b/config/constants.go index 28dffe83..0fbbef89 100644 --- a/config/constants.go +++ b/config/constants.go @@ -61,7 +61,7 @@ const ( // Plugin constants. DefaultMinPort = 50000 DefaultMaxPort = 60000 - PluginPriorityStart = 1000 + PluginPriorityStart = uint(1000) DefaultPluginAddress = "http://plugins/metrics" DefaultMetricsMergerPeriod = 5 * time.Second DefaultPluginHealthCheckPeriod = 5 * time.Second diff --git a/network/roundrobin_test.go b/network/roundrobin_test.go index 259e8c56..9f98d6ac 100644 --- a/network/roundrobin_test.go +++ b/network/roundrobin_test.go @@ -74,7 +74,7 @@ func TestRoundRobin_ConcurrentAccess(t *testing.T) { waitGroup.Wait() nextIndex := roundRobin.next.Load() - if nextIndex != uint32(numGoroutines) { //nolint:gosec + if nextIndex != uint32(numGoroutines) { t.Errorf("expected next index to be %d, got %d", numGoroutines, nextIndex) } } diff --git a/network/server.go b/network/server.go index ec919d72..0858976c 100644 --- a/network/server.go +++ b/network/server.go @@ -241,7 +241,7 @@ func (s *Server) OnClose(conn *ConnWrapper, err error) Action { // Shutdown the server if there are no more connections and the server is stopped. // This is used to shut down the server gracefully. - if uint64(s.CountConnections()) == 0 && !s.IsRunning() { + if s.CountConnections() == 0 && !s.IsRunning() { span.AddEvent("Shutting down the server") return Shutdown } diff --git a/plugin/plugin_registry.go b/plugin/plugin_registry.go index f486bfe2..b5130d52 100644 --- a/plugin/plugin_registry.go +++ b/plugin/plugin_registry.go @@ -477,7 +477,8 @@ func (reg *Registry) LoadPlugins( // in the config file. Built-in plugins are loaded first, followed by user-defined // plugins. Built-in plugins have a priority of 0 to 999, and user-defined plugins // have a priority of 1000 or greater. - plugin.Priority = sdkPlugin.Priority(config.PluginPriorityStart + uint(priority)) + plugin.Priority = sdkPlugin.Priority( + config.PluginPriorityStart + uint(priority)) //nolint:gosec logAdapter := logging.NewHcLogAdapter(®.Logger, pCfg.Name) diff --git a/plugin/plugin_registry_test.go b/plugin/plugin_registry_test.go index 4a33d910..fcd66294 100644 --- a/plugin/plugin_registry_test.go +++ b/plugin/plugin_registry_test.go @@ -167,7 +167,7 @@ func BenchmarkHookRun(b *testing.B) { args.Fields["test"] = v1.NewStringValue("test1") return args, nil } - for priority := range 1000 { + for priority := range uint(1000) { reg.AddHook(v1.HookName_HOOK_NAME_ON_NEW_LOGGER, sdkPlugin.Priority(priority), hookFunction,