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 f5a004d
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 44 deletions.
2 changes: 1 addition & 1 deletion api/api/projects_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions api/api/secrets_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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")
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
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, _ []string) {
bootstrapConfig, err := loadBootstrapConfig(bootstrapConfigFile)
if err != nil {
log.Panicf("unable to load role members from input file: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions 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, _ []string) {
serveConfig, err := config.LoadAndValidate(configFiles...)
if err != nil {
log.Fatalf("failed initializing config: %v", err)
Expand Down Expand Up @@ -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("{}")
Expand Down
4 changes: 2 additions & 2 deletions api/it/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down
5 changes: 3 additions & 2 deletions api/pkg/artifact/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

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
12 changes: 6 additions & 6 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 Expand Up @@ -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))
Expand Down Expand Up @@ -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))
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
4 changes: 2 additions & 2 deletions api/pkg/instrumentation/newrelic/newrelic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
})

Expand Down Expand Up @@ -133,6 +133,6 @@ func TestRecordCustomMetric(t *testing.T) {
assert.Nil(t, err)
}

func TestShutdown(t *testing.T) {
func TestShutdown(_ *testing.T) {
Shutdown(100)
}
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
2 changes: 1 addition & 1 deletion api/service/projects_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f5a004d

Please sign in to comment.