diff --git a/api/cmd/bootstrap.go b/api/cmd/bootstrap.go index e69ac9a6..ecdd60c6 100644 --- a/api/cmd/bootstrap.go +++ b/api/cmd/bootstrap.go @@ -25,7 +25,7 @@ var ( bootstrapCmd = &cobra.Command{ Use: "bootstrap", Short: "Start bootstrap job to populate Keto", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { bootstrapConfig, err := loadBootstrapConfig(bootstrapConfigFile) if err != nil { log.Panicf("unable to load role members from input file: %v", err) diff --git a/api/cmd/serve.go b/api/cmd/serve.go index e142c743..45db2130 100644 --- a/api/cmd/serve.go +++ b/api/cmd/serve.go @@ -28,7 +28,7 @@ var ( serveCmd = &cobra.Command{ Use: "serve", Short: "Start MLP API server", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, args []string) { serveConfig, err := config.LoadAndValidate(configFiles...) if err != nil { log.Fatalf("failed initializing config: %v", err) diff --git a/api/it/database/database.go b/api/it/database/database.go index 5c969e46..07814b82 100644 --- a/api/it/database/database.go +++ b/api/it/database/database.go @@ -32,9 +32,8 @@ func create(conn *sql.DB, dbName string) (*sql.DB, error) { log.Fatalf("Failed to cleanup integration test database: \n%s", err) } return nil, err - } else { - return testDb, nil } + return testDb, nil } func migrate(db *sql.DB, dbName string) (*sql.DB, error) { @@ -87,9 +86,8 @@ func CreateTestDatabase() (*gorm.DB, func(), error) { } else if gormDb, err := gorm.Open("postgres", testDb); err != nil { cleanup() return nil, nil, err - } else { - return gormDb, cleanup, nil } + return gormDb, cleanup, nil } func WithTestDatabase(t *testing.T, test func(t *testing.T, db *gorm.DB)) { diff --git a/api/pkg/authz/enforcer/enforcer.go b/api/pkg/authz/enforcer/enforcer.go index 1ba30545..cb352c59 100644 --- a/api/pkg/authz/enforcer/enforcer.go +++ b/api/pkg/authz/enforcer/enforcer.go @@ -158,7 +158,7 @@ func (e *enforcer) GetUserPermissions(ctx context.Context, user string) ([]strin return nil, err } permissions := make([]string, 0) - permissionSet.Range(func(key, value interface{}) bool { + permissionSet.Range(func(key, _ interface{}) bool { permissions = append(permissions, key.(string)) return true }) diff --git a/api/pkg/client/mlflow/mlflow_test.go b/api/pkg/client/mlflow/mlflow_test.go index 187f6b00..630331b4 100644 --- a/api/pkg/client/mlflow/mlflow_test.go +++ b/api/pkg/client/mlflow/mlflow_test.go @@ -348,7 +348,7 @@ func TestMlflowClient_SearchRunForExperiment(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) _, err := w.Write([]byte(tc.expectedRespJSON)) @@ -416,7 +416,7 @@ func TestMlflowClient_SearchRunData(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(tc.httpStatus) _, err := w.Write([]byte(tc.expectedRespJSON)) diff --git a/api/pkg/instrumentation/metrics/nop.go b/api/pkg/instrumentation/metrics/nop.go index 7df378a2..e95df10a 100644 --- a/api/pkg/instrumentation/metrics/nop.go +++ b/api/pkg/instrumentation/metrics/nop.go @@ -35,6 +35,6 @@ func (NopMetricsCollector) RecordGauge(MetricName, float64, map[string]string) e } // Inc satisfies the Collector interface -func (c NopMetricsCollector) Inc(key MetricName, labels map[string]string) error { +func (c NopMetricsCollector) Inc(_ MetricName, _ map[string]string) error { return nil } diff --git a/api/pkg/instrumentation/metrics/prometheus_test.go b/api/pkg/instrumentation/metrics/prometheus_test.go index 81fd72c6..1f3aa85c 100644 --- a/api/pkg/instrumentation/metrics/prometheus_test.go +++ b/api/pkg/instrumentation/metrics/prometheus_test.go @@ -45,7 +45,7 @@ type mockCounterVec struct { counter *mockCounter } -func (m mockCounterVec) GetMetricWith(labels prometheus.Labels) (prometheus.Counter, error) { +func (m mockCounterVec) GetMetricWith(_ prometheus.Labels) (prometheus.Counter, error) { return m.counter, nil } @@ -95,7 +95,7 @@ type mockGaugeVec struct { gauge *mockGauge } -func (g *mockGaugeVec) GetMetricWith(labels prometheus.Labels) (prometheus.Gauge, error) { +func (g *mockGaugeVec) GetMetricWith(_ prometheus.Labels) (prometheus.Gauge, error) { return g.gauge, nil } @@ -105,7 +105,7 @@ func createMockGaugeVec(testValue float64) *mockGaugeVec { gauge := &mockGauge{ value: 0, } - gauge.On("Set", mock.Anything).Run(func(args mock.Arguments) { + gauge.On("Set", mock.Anything).Run(func(_ mock.Arguments) { gauge.value = testValue }).Return(nil) gaugeVec := &mockGaugeVec{ @@ -145,7 +145,7 @@ type mockHistogramVec struct { histogram *mockHistogram } -func (h *mockHistogramVec) GetMetricWith(labels prometheus.Labels) (prometheus.Observer, error) { +func (h *mockHistogramVec) GetMetricWith(_ prometheus.Labels) (prometheus.Observer, error) { return h.histogram, nil } @@ -207,7 +207,7 @@ func createMockHistVec(testDuration float64) *mockHistogramVec { hist := &mockHistogram{ duration: 0, } - hist.On("Observe", mock.Anything).Run(func(args mock.Arguments) { + hist.On("Observe", mock.Anything).Run(func(_ mock.Arguments) { hist.duration = testDuration }).Return(nil) return &mockHistogramVec{ diff --git a/api/pkg/instrumentation/newrelic/noop.go b/api/pkg/instrumentation/newrelic/noop.go index bba66202..df361d94 100644 --- a/api/pkg/instrumentation/newrelic/noop.go +++ b/api/pkg/instrumentation/newrelic/noop.go @@ -12,25 +12,25 @@ import ( type NoopApp struct{} // StartTransaction implements newrelic.Application interface. -func (na NoopApp) StartTransaction(name string, w http.ResponseWriter, r *http.Request) newrelic.Transaction { +func (na NoopApp) StartTransaction(_ string, w http.ResponseWriter, _ *http.Request) newrelic.Transaction { return &NoopTx{ w: w, } } // RecordCustomEvent implements newrelic.Application interface. -func (na NoopApp) RecordCustomEvent(eventType string, params map[string]interface{}) error { +func (na NoopApp) RecordCustomEvent(_ string, _ map[string]interface{}) error { return nil } // RecordCustomMetric implements newrelic.Application interface. -func (na NoopApp) RecordCustomMetric(name string, value float64) error { return nil } +func (na NoopApp) RecordCustomMetric(_ string, _ float64) error { return nil } // WaitForConnection implements newrelic.Application interface. -func (na NoopApp) WaitForConnection(timeout time.Duration) error { return nil } +func (na NoopApp) WaitForConnection(_ time.Duration) error { return nil } // Shutdown implements newrelic.Application interface. -func (na NoopApp) Shutdown(timeout time.Duration) { +func (na NoopApp) Shutdown(_ time.Duration) { // Do nothing } @@ -55,17 +55,17 @@ func (nt *NoopTx) Ignore() error { } // SetName implements newrelic.Transaction interface. -func (nt *NoopTx) SetName(name string) error { +func (nt *NoopTx) SetName(_ string) error { return nil } // NoticeError implements newrelic.Transaction interface. -func (nt *NoopTx) NoticeError(err error) error { +func (nt *NoopTx) NoticeError(_ error) error { return nil } // AddAttribute implements newrelic.Transaction interface. -func (nt *NoopTx) AddAttribute(key string, value interface{}) error { +func (nt *NoopTx) AddAttribute(_ string, _ interface{}) error { return nil } @@ -90,7 +90,7 @@ func (nt *NoopTx) CreateDistributedTracePayload() newrelic.DistributedTracePaylo } // AcceptDistributedTracePayload implements newrelic.Transaction interface. -func (nt *NoopTx) AcceptDistributedTracePayload(t newrelic.TransportType, payload interface{}) error { +func (nt *NoopTx) AcceptDistributedTracePayload(_ newrelic.TransportType, _ interface{}) error { return nil } diff --git a/api/pkg/instrumentation/newrelic/noop_test.go b/api/pkg/instrumentation/newrelic/noop_test.go index 02a75f1e..b4f8a4b2 100644 --- a/api/pkg/instrumentation/newrelic/noop_test.go +++ b/api/pkg/instrumentation/newrelic/noop_test.go @@ -8,7 +8,7 @@ import ( newrelic "github.com/newrelic/go-agent" ) -func TestNoopApp(t *testing.T) { +func TestNoopApp(_ *testing.T) { na := NoopApp{} _ = na.StartTransaction("test", httptest.NewRecorder(), &http.Request{}) _ = na.RecordCustomEvent("test", nil) @@ -17,7 +17,7 @@ func TestNoopApp(t *testing.T) { na.Shutdown(0) } -func TestNoopTx(t *testing.T) { +func TestNoopTx(_ *testing.T) { nt := NoopTx{ w: httptest.NewRecorder(), } diff --git a/api/pkg/instrumentation/sentry/noop.go b/api/pkg/instrumentation/sentry/noop.go index 960ec969..210b6748 100644 --- a/api/pkg/instrumentation/sentry/noop.go +++ b/api/pkg/instrumentation/sentry/noop.go @@ -7,12 +7,12 @@ import raven "github.com/getsentry/raven-go" type NoopClient struct{} // Capture implements Client interface. -func (nc *NoopClient) Capture(packet *raven.Packet, captureTags map[string]string) (eventID string, ch chan error) { +func (nc *NoopClient) Capture(_ *raven.Packet, _ map[string]string) (eventID string, ch chan error) { return "", nil } // CaptureError implements Client interface. -func (nc *NoopClient) CaptureError(err error, tags map[string]string, interfaces ...raven.Interface) string { +func (nc *NoopClient) CaptureError(_ error, _ map[string]string, _ ...raven.Interface) string { return "" } diff --git a/api/pkg/instrumentation/sentry/noop_test.go b/api/pkg/instrumentation/sentry/noop_test.go index 7f62960f..d3a4bbad 100644 --- a/api/pkg/instrumentation/sentry/noop_test.go +++ b/api/pkg/instrumentation/sentry/noop_test.go @@ -4,7 +4,7 @@ import ( "testing" ) -func TestNoopClient(t *testing.T) { +func TestNoopClient(_ *testing.T) { nc := &NoopClient{} nc.Capture(nil, nil) nc.CaptureError(nil, nil, nil) diff --git a/api/pkg/instrumentation/sentry/sentry_test.go b/api/pkg/instrumentation/sentry/sentry_test.go index c9d9b723..ffff52e8 100644 --- a/api/pkg/instrumentation/sentry/sentry_test.go +++ b/api/pkg/instrumentation/sentry/sentry_test.go @@ -60,7 +60,7 @@ func TestSentry(t *testing.T) { sentry := Sentry() assert.NotNil(t, sentry) - panicHandler := RecoveryHandler(func(w http.ResponseWriter, r *http.Request) { + panicHandler := RecoveryHandler(func(_ http.ResponseWriter, _ *http.Request) { panic("at the disco") }) assert.NotNil(t, panicHandler)