Skip to content

Commit

Permalink
Fix linter comments
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlycoconuts committed Sep 9, 2024
1 parent f54c70c commit de72ee9
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion api/cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions api/it/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 36 in api/it/database/database.go

View workflow job for this annotation

GitHub Actions / test-api

undefined: testDb

Check failure on line 36 in api/it/database/database.go

View workflow job for this annotation

GitHub Actions / test-api

undefined: testDb
}

func migrate(db *sql.DB, dbName string) (*sql.DB, error) {
Expand Down Expand Up @@ -87,9 +86,8 @@ func CreateTestDatabase() (*gorm.DB, func(), error) {
} else if gormDb, err := gorm.Open("postgres", testDb); err != nil {

Check failure on line 86 in api/it/database/database.go

View workflow job for this annotation

GitHub Actions / test-api

gormDb declared and not used

Check failure on line 86 in api/it/database/database.go

View workflow job for this annotation

GitHub Actions / test-api

gormDb declared and not used
cleanup()
return nil, nil, err
} else {
return gormDb, cleanup, nil
}
return gormDb, cleanup, nil

Check failure on line 90 in api/it/database/database.go

View workflow job for this annotation

GitHub Actions / test-api

undefined: gormDb (typecheck)

Check failure on line 90 in api/it/database/database.go

View workflow job for this annotation

GitHub Actions / test-api

undefined: gormDb) (typecheck)
}

func WithTestDatabase(t *testing.T, test func(t *testing.T, db *gorm.DB)) {
Expand Down
2 changes: 1 addition & 1 deletion api/pkg/authz/enforcer/enforcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 2 additions & 2 deletions api/pkg/client/mlflow/mlflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion api/pkg/instrumentation/metrics/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 5 additions & 5 deletions api/pkg/instrumentation/metrics/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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{
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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{
Expand Down
18 changes: 9 additions & 9 deletions api/pkg/instrumentation/newrelic/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions api/pkg/instrumentation/newrelic/noop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(),
}
Expand Down
4 changes: 2 additions & 2 deletions api/pkg/instrumentation/sentry/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}

Expand Down
2 changes: 1 addition & 1 deletion api/pkg/instrumentation/sentry/noop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/pkg/instrumentation/sentry/sentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit de72ee9

Please sign in to comment.