diff --git a/api/api/projects_api.go b/api/api/projects_api.go index 1a0ce1cb..ac8751a8 100644 --- a/api/api/projects_api.go +++ b/api/api/projects_api.go @@ -104,7 +104,7 @@ func (c *ProjectsController) UpdateProject(r *http.Request, vars map[string]stri return Ok(updatedProject) } -func (c *ProjectsController) GetProject(r *http.Request, vars map[string]string, body interface{}) *Response { +func (c *ProjectsController) GetProject(_ *http.Request, vars map[string]string, _ interface{}) *Response { projectID, _ := models.ParseID(vars["project_id"]) project, err := c.ProjectsService.FindByID(projectID) if err != nil { diff --git a/api/api/secrets_api.go b/api/api/secrets_api.go index 34aafc93..c40f5879 100644 --- a/api/api/secrets_api.go +++ b/api/api/secrets_api.go @@ -14,7 +14,7 @@ type SecretsController struct { *AppContext } -func (c *SecretsController) GetSecret(r *http.Request, vars map[string]string, _ interface{}) *Response { +func (c *SecretsController) GetSecret(_ *http.Request, vars map[string]string, _ interface{}) *Response { projectID, _ := models.ParseID(vars["project_id"]) secretID, _ := models.ParseID(vars["secret_id"]) if projectID <= 0 || secretID <= 0 { @@ -31,7 +31,7 @@ func (c *SecretsController) GetSecret(r *http.Request, vars map[string]string, _ return Ok(secret) } -func (c *SecretsController) CreateSecret(r *http.Request, vars map[string]string, body interface{}) *Response { +func (c *SecretsController) CreateSecret(_ *http.Request, vars map[string]string, body interface{}) *Response { projectID, _ := models.ParseID(vars["project_id"]) _, err := c.ProjectsService.FindByID(projectID) if err != nil { @@ -56,7 +56,7 @@ func (c *SecretsController) CreateSecret(r *http.Request, vars map[string]string return Created(secret) } -func (c *SecretsController) UpdateSecret(r *http.Request, vars map[string]string, body interface{}) *Response { +func (c *SecretsController) UpdateSecret(_ *http.Request, vars map[string]string, body interface{}) *Response { updateRequest, ok := body.(*models.Secret) if !ok { return BadRequest("Invalid request body") @@ -87,7 +87,7 @@ func (c *SecretsController) UpdateSecret(r *http.Request, vars map[string]string return Ok(updatedSecret) } -func (c *SecretsController) DeleteSecret(r *http.Request, vars map[string]string, _ interface{}) *Response { +func (c *SecretsController) DeleteSecret(_ *http.Request, vars map[string]string, _ interface{}) *Response { projectID, _ := models.ParseID(vars["project_id"]) secretID, _ := models.ParseID(vars["secret_id"]) if projectID <= 0 || secretID <= 0 { @@ -102,7 +102,7 @@ func (c *SecretsController) DeleteSecret(r *http.Request, vars map[string]string return NoContent() } -func (c *SecretsController) ListSecret(r *http.Request, vars map[string]string, body interface{}) *Response { +func (c *SecretsController) ListSecret(_ *http.Request, vars map[string]string, _ interface{}) *Response { projectID, _ := models.ParseID(vars["project_id"]) _, err := c.ProjectsService.FindByID(projectID) if err != nil { diff --git a/api/cmd/bootstrap.go b/api/cmd/bootstrap.go index e69ac9a6..5904620e 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, _ []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..7546e65a 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, _ []string) { serveConfig, err := config.LoadAndValidate(configFiles...) if err != nil { log.Fatalf("failed initializing config: %v", err) @@ -118,7 +118,7 @@ type uiEnvHandler struct { LabelsBlacklist []string `json:"REACT_APP_LABELS_BLACKLIST"` } -func (h uiEnvHandler) handler(w http.ResponseWriter, r *http.Request) { +func (h uiEnvHandler) handler(w http.ResponseWriter, _ *http.Request) { envJSON, err := json.Marshal(h) if err != nil { envJSON = []byte("{}") diff --git a/api/it/database/database.go b/api/it/database/database.go index 5c969e46..3ce61156 100644 --- a/api/it/database/database.go +++ b/api/it/database/database.go @@ -32,7 +32,7 @@ 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 { + } else { //nolint:revive // https://github.com/mgechev/revive/issues/564 (false positive) return testDb, nil } } @@ -87,7 +87,7 @@ func CreateTestDatabase() (*gorm.DB, func(), error) { } else if gormDb, err := gorm.Open("postgres", testDb); err != nil { cleanup() return nil, nil, err - } else { + } else { //nolint:revive // https://github.com/mgechev/revive/issues/564 (false positive) return gormDb, cleanup, nil } } diff --git a/api/pkg/artifact/artifact.go b/api/pkg/artifact/artifact.go index 88bb6129..69e2cb67 100644 --- a/api/pkg/artifact/artifact.go +++ b/api/pkg/artifact/artifact.go @@ -4,14 +4,15 @@ import ( "bytes" "context" "fmt" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/s3" + "io" "net/url" "strings" "cloud.google.com/go/storage" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" + "github.com/aws/aws-sdk-go-v2/service/s3" "google.golang.org/api/iterator" ) 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..4bd03f76 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)) @@ -477,13 +477,13 @@ func TestMlflowClient_DeleteExperiment(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { mux := http.NewServeMux() - mux.HandleFunc("/api/2.0/mlflow/runs/delete", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/2.0/mlflow/runs/delete", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(tc.httpStatus) _, err := w.Write([]byte(tc.expectedRespJSON)) require.NoError(t, err) }) - mux.HandleFunc("/api/2.0/mlflow/runs/search", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/2.0/mlflow/runs/search", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(tc.httpStatus) _, err := w.Write([]byte(tc.expectedRunsRespJSON)) @@ -604,13 +604,13 @@ func TestMlflowClient_DeleteRun(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { mux := http.NewServeMux() - mux.HandleFunc("/api/2.0/mlflow/runs/delete", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/2.0/mlflow/runs/delete", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(tc.httpStatus) _, err := w.Write([]byte(tc.expectedRespJSON)) require.NoError(t, err) }) - mux.HandleFunc("/api/2.0/mlflow/runs/get", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/api/2.0/mlflow/runs/get", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(tc.httpStatus) _, err := w.Write([]byte(tc.expectedRunRespJSON)) 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/newrelic_test.go b/api/pkg/instrumentation/newrelic/newrelic_test.go index a3a23f62..6ad08ba2 100644 --- a/api/pkg/instrumentation/newrelic/newrelic_test.go +++ b/api/pkg/instrumentation/newrelic/newrelic_test.go @@ -84,7 +84,7 @@ func TestInitNewRelic(t *testing.T) { } func TestWrapHandleFunc(t *testing.T) { - pattern, handler := WrapHandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) { + pattern, handler := WrapHandleFunc("/ping", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("pong")) }) @@ -133,6 +133,6 @@ func TestRecordCustomMetric(t *testing.T) { assert.Nil(t, err) } -func TestShutdown(t *testing.T) { +func TestShutdown(_ *testing.T) { Shutdown(100) } 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) diff --git a/api/service/projects_service_test.go b/api/service/projects_service_test.go index 88587ff9..7114b814 100644 --- a/api/service/projects_service_test.go +++ b/api/service/projects_service_test.go @@ -898,7 +898,7 @@ func Test_sendUpdateRequest(t *testing.T) { "stream": "team-2", } - 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(`{"status":"success","message":"success-message"}`)) assert.NoError(t, err)