From b3a9f6ab2e5211101b6f8ac87d4fd5cd80d604e5 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 8 Feb 2024 08:30:23 +0100 Subject: [PATCH] chore: remove unused parameters They were not detected by revive in function literals. --- cmd/conntrack-fixer.go | 2 +- cmd/healthcheck.go | 2 +- cmd/root.go | 2 +- cmd/version.go | 2 +- common/helpers/mapstructure_test.go | 2 +- common/remotedatasourcefetcher/root_test.go | 2 +- conntrackfixer/root_test.go | 2 +- inlet/flow/input/udp/socket.go | 2 +- inlet/flow/root.go | 2 +- inlet/metadata/provider/static/source_test.go | 4 ++-- inlet/routing/provider/bmp/rib.go | 2 +- orchestrator/clickhouse/http.go | 8 ++++---- orchestrator/clickhouse/source_test.go | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/conntrack-fixer.go b/cmd/conntrack-fixer.go index 32d78ea0..cc0b1b1e 100644 --- a/cmd/conntrack-fixer.go +++ b/cmd/conntrack-fixer.go @@ -22,7 +22,7 @@ var conntrackFixerCmd = &cobra.Command{ Long: `This helper cleans the conntrack entries for the UDP ports exposed by containers started with the label "akvorado.conntrack.fix=1".`, Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, _ []string) error { // This is a simplified service which is not configurable. r, err := reporter.New(reporter.DefaultConfiguration()) if err != nil { diff --git a/cmd/healthcheck.go b/cmd/healthcheck.go index 3a86697a..4d768130 100644 --- a/cmd/healthcheck.go +++ b/cmd/healthcheck.go @@ -17,7 +17,7 @@ var healthcheckCmd = &cobra.Command{ Use: "healthcheck", Short: "Check healthness", Long: `Check if Akvorado is alive using the builtin HTTP endpoint.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { resp, err := http.Get("http://localhost:8080/api/v0/healthcheck") if err != nil { return err diff --git a/cmd/root.go b/cmd/root.go index 97469b7e..ad0b7f58 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -19,7 +19,7 @@ var debug bool var RootCmd = &cobra.Command{ Use: "akvorado", Short: "Flow collector, enricher and visualizer", - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(_ *cobra.Command, _ []string) { if isatty.IsTerminal(os.Stdout.Fd()) { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) } else { diff --git a/cmd/version.go b/cmd/version.go index 01b79d4c..eaaeec18 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -30,7 +30,7 @@ var versionCmd = &cobra.Command{ Use: "version", Short: "Print version", Long: `Display version and build information about akvorado.`, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { cmd.Printf("akvorado %s\n", Version) cmd.Printf(" Built with: %s\n", runtime.Version()) cmd.Println() diff --git a/common/helpers/mapstructure_test.go b/common/helpers/mapstructure_test.go index 30060191..d1105149 100644 --- a/common/helpers/mapstructure_test.go +++ b/common/helpers/mapstructure_test.go @@ -41,7 +41,7 @@ func TestProtectedDecodeHook(t *testing.T) { A string B string } - panicHook := func(from, to reflect.Type, data interface{}) (interface{}, error) { + panicHook := func(from, _ reflect.Type, data interface{}) (interface{}, error) { if from.Kind() == reflect.String { panic(errors.New("noooo")) } diff --git a/common/remotedatasourcefetcher/root_test.go b/common/remotedatasourcefetcher/root_test.go index cc7bca36..a1157fd0 100644 --- a/common/remotedatasourcefetcher/root_test.go +++ b/common/remotedatasourcefetcher/root_test.go @@ -42,7 +42,7 @@ func TestRemoteDataSourceFetcher(t *testing.T) { // Mux to answer requests ready := make(chan bool) mux := http.NewServeMux() - mux.Handle("/data.json", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mux.Handle("/data.json", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { select { case <-ready: default: diff --git a/conntrackfixer/root_test.go b/conntrackfixer/root_test.go index 8a74db31..45dcdcc9 100644 --- a/conntrackfixer/root_test.go +++ b/conntrackfixer/root_test.go @@ -130,7 +130,7 @@ func TestRoot(t *testing.T) { }) // New container - t.Run("new container", func(t *testing.T) { + t.Run("new container", func(_ *testing.T) { dockerClientMock.EXPECT(). ContainerList(gomock.Any(), gomock.Any()). Return([]types.Container{{ID: "new one"}}, nil) diff --git a/inlet/flow/input/udp/socket.go b/inlet/flow/input/udp/socket.go index e13b90ef..88adfe01 100644 --- a/inlet/flow/input/udp/socket.go +++ b/inlet/flow/input/udp/socket.go @@ -18,7 +18,7 @@ type oobMessage struct { // listenConfig configures a listening socket to reuse port and return overflows var listenConfig = net.ListenConfig{ - Control: func(network, address string, c syscall.RawConn) error { + Control: func(_, _ string, c syscall.RawConn) error { var err error c.Control(func(fd uintptr) { opts := udpSocketOptions diff --git a/inlet/flow/root.go b/inlet/flow/root.go index d8acb5fe..41f0278b 100644 --- a/inlet/flow/root.go +++ b/inlet/flow/root.go @@ -110,7 +110,7 @@ func New(r *reporter.Reporter, configuration Configuration, dependencies Depende c.d.Daemon.Track(&c.t, "inlet/flow") c.d.HTTP.AddHandler("/api/v0/inlet/flow/schema.proto", - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "text/plain") w.Write([]byte(c.d.Schema.ProtobufDefinition())) })) diff --git a/inlet/metadata/provider/static/source_test.go b/inlet/metadata/provider/static/source_test.go index 1e000ba9..375eb495 100644 --- a/inlet/metadata/provider/static/source_test.go +++ b/inlet/metadata/provider/static/source_test.go @@ -38,7 +38,7 @@ func TestInitStaticExporters(t *testing.T) { p := &Provider{ r: r, exportersMap: map[string][]exporterInfo{}, - put: func(update provider.Update) {}, + put: func(_ provider.Update) {}, } p.exporters.Store(conf.Exporters) @@ -73,7 +73,7 @@ func TestRemoteExporterSources(t *testing.T) { // Mux to answer requests ready := make(chan bool) mux := http.NewServeMux() - mux.Handle("/exporters.json", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mux.Handle("/exporters.json", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { select { case <-ready: default: diff --git a/inlet/routing/provider/bmp/rib.go b/inlet/routing/provider/bmp/rib.go index 67333a2a..a7cd567d 100644 --- a/inlet/routing/provider/bmp/rib.go +++ b/inlet/routing/provider/bmp/rib.go @@ -200,7 +200,7 @@ func (r *rib) flushPeerContext(ctx context.Context, peer uint32, steps int) (int iter := r.tree.Iterate() runtime.Gosched() for iter.Next() { - removed += iter.DeleteWithBuffer(buf, func(payload route, val route) bool { + removed += iter.DeleteWithBuffer(buf, func(payload route, _ route) bool { if payload.peer == peer { r.nlris.Take(payload.nlri) r.nextHops.Take(payload.nextHop) diff --git a/orchestrator/clickhouse/http.go b/orchestrator/clickhouse/http.go index e99cb987..88d433eb 100644 --- a/orchestrator/clickhouse/http.go +++ b/orchestrator/clickhouse/http.go @@ -81,7 +81,7 @@ func (c *Component) addHandlerEmbedded(url string, path string) { func (c *Component) registerHTTPHandlers() error { // init.sh c.d.HTTP.AddHandler("/api/v0/orchestrator/clickhouse/init.sh", - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { var result bytes.Buffer if err := initShTemplate.Execute(&result, initShVariables{ FlowSchemaHash: c.d.Schema.ProtobufMessageHash(), @@ -109,7 +109,7 @@ func (c *Component) registerHTTPHandlers() error { for name, dict := range c.d.Schema.GetCustomDictConfig() { name := name dict := dict - c.d.HTTP.AddHandler(fmt.Sprintf("/api/v0/orchestrator/clickhouse/custom_dict_%s.csv", name), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + c.d.HTTP.AddHandler(fmt.Sprintf("/api/v0/orchestrator/clickhouse/custom_dict_%s.csv", name), http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { file, err := os.ReadFile(dict.Source) if err != nil { c.r.Err(err).Msg("unable to deliver custom dict csv file") @@ -123,7 +123,7 @@ func (c *Component) registerHTTPHandlers() error { // networks.csv c.d.HTTP.AddHandler("/api/v0/orchestrator/clickhouse/networks.csv", - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { select { case <-c.networkSourcesFetcher.DataSourcesReady: case <-time.After(c.config.NetworkSourcesTimeout): @@ -155,7 +155,7 @@ func (c *Component) registerHTTPHandlers() error { // asns.csv (when there are some custom-defined ASNs) if len(c.config.ASNs) != 0 { c.d.HTTP.AddHandler("/api/v0/orchestrator/clickhouse/asns.csv", - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { f, err := data.Open("data/asns.csv") if err != nil { c.r.Err(err).Msg("unable to open data/asns.csv") diff --git a/orchestrator/clickhouse/source_test.go b/orchestrator/clickhouse/source_test.go index 6ff00602..51207e81 100644 --- a/orchestrator/clickhouse/source_test.go +++ b/orchestrator/clickhouse/source_test.go @@ -24,7 +24,7 @@ func TestNetworkSources(t *testing.T) { // Mux to answer requests ready := make(chan bool) mux := http.NewServeMux() - mux.Handle("/amazon.json", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mux.Handle("/amazon.json", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { select { case <-ready: default: