From a937793edb9e60cb9e271e07d533c33b1beea9e0 Mon Sep 17 00:00:00 2001 From: Atefeh Mohseni-Ejiyeh Date: Fri, 9 Feb 2024 01:15:15 +0000 Subject: [PATCH] fix lint errors (#1034) --- app/api/controller/check/check_report.go | 2 +- app/api/controller/check/sanitizers.go | 12 ++++++------ app/api/handler/resource/resource.go | 4 ++-- app/api/render/render_test.go | 4 ++-- app/auth/authn/jwt.go | 2 +- app/router/git.go | 2 +- app/router/web.go | 2 +- app/sse/sse.go | 2 +- events/wire.go | 2 +- lock/memory.go | 2 +- lock/options.go | 2 +- store/database/dbtx/runner_test.go | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/api/controller/check/check_report.go b/app/api/controller/check/check_report.go index 1c831183d..bde2cd91a 100644 --- a/app/api/controller/check/check_report.go +++ b/app/api/controller/check/check_report.go @@ -50,7 +50,7 @@ var matcherCheckIdentifier = regexp.MustCompile(regexpCheckIdentifier) // Sanitize validates and sanitizes the ReportInput data. func (in *ReportInput) Sanitize( - sanitizers map[enum.CheckPayloadKind]func(in *ReportInput, session *auth.Session) error, session *auth.Session, + sanitizers map[enum.CheckPayloadKind]func(in *ReportInput, s *auth.Session) error, session *auth.Session, ) error { // TODO [CODE-1363]: remove after identifier migration. if in.Identifier == "" { diff --git a/app/api/controller/check/sanitizers.go b/app/api/controller/check/sanitizers.go index 8d26752fc..0dfb4ff2e 100644 --- a/app/api/controller/check/sanitizers.go +++ b/app/api/controller/check/sanitizers.go @@ -35,8 +35,8 @@ func ProvideCheckSanitizers() map[enum.CheckPayloadKind]func(in *ReportInput, s return registeredCheckSanitizers } -func createEmptyPayloadSanitizer() func(in *ReportInput, s *auth.Session) error { - return func(in *ReportInput, s *auth.Session) error { +func createEmptyPayloadSanitizer() func(in *ReportInput, _ *auth.Session) error { + return func(in *ReportInput, _ *auth.Session) error { // the default payload kind (empty) does not support the payload data: clear it here in.Payload.Version = "" in.Payload.Data = []byte("{}") @@ -49,8 +49,8 @@ func createEmptyPayloadSanitizer() func(in *ReportInput, s *auth.Session) error } } -func createRawPayloadSanitizer() func(in *ReportInput, s *auth.Session) error { - return func(in *ReportInput, s *auth.Session) error { +func createRawPayloadSanitizer() func(in *ReportInput, _ *auth.Session) error { + return func(in *ReportInput, _ *auth.Session) error { // the text payload kinds (raw and markdown) do not support the version if in.Payload.Version != "" { return usererror.BadRequestf("Payload version must be empty for the payload kind '%s'", @@ -68,8 +68,8 @@ func createRawPayloadSanitizer() func(in *ReportInput, s *auth.Session) error { } } -func createPipelinePayloadSanitizer() func(in *ReportInput, s *auth.Session) error { - return func(in *ReportInput, s *auth.Session) error { +func createPipelinePayloadSanitizer() func(in *ReportInput, _ *auth.Session) error { + return func(_ *ReportInput, _ *auth.Session) error { return usererror.BadRequest("Kind cannot be pipeline for external checks") } } diff --git a/app/api/handler/resource/resource.go b/app/api/handler/resource/resource.go index 95d6267a3..9c893cb42 100644 --- a/app/api/handler/resource/resource.go +++ b/app/api/handler/resource/resource.go @@ -22,7 +22,7 @@ import ( ) func HandleGitIgnore() http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { files, err := resources.GitIgnores() if err != nil { render.ErrorMessagef(w, http.StatusInternalServerError, "error loading gitignore files: %v", err) @@ -33,7 +33,7 @@ func HandleGitIgnore() http.HandlerFunc { } func HandleLicence() http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { response, err := resources.Licenses() if err != nil { render.ErrorMessagef(w, http.StatusInternalServerError, "error loading licence file: %v", err) diff --git a/app/api/render/render_test.go b/app/api/render/render_test.go index c454dff62..467cfa6ac 100644 --- a/app/api/render/render_test.go +++ b/app/api/render/render_test.go @@ -185,7 +185,7 @@ func TestJSONArrayDynamic(t *testing.T) { name: "happy path", args: args[*mock]{ ctx: noctx, - f: func(ch chan<- *mock, cherr chan<- error) { + f: func(ch chan<- *mock, _ chan<- error) { defer close(ch) ch <- &mock{ID: 1} }, @@ -197,7 +197,7 @@ func TestJSONArrayDynamic(t *testing.T) { name: "empty array response", args: args[*mock]{ ctx: noctx, - f: func(ch chan<- *mock, cherr chan<- error) { + f: func(ch chan<- *mock, _ chan<- error) { close(ch) }, }, diff --git a/app/auth/authn/jwt.go b/app/auth/authn/jwt.go index 00b7d2dfb..902abb01e 100644 --- a/app/auth/authn/jwt.go +++ b/app/auth/authn/jwt.go @@ -62,7 +62,7 @@ func (a *JWTAuthenticator) Authenticate(r *http.Request) (*auth.Session, error) var principal *types.Principal var err error claims := &jwt.Claims{} - parsed, err := gojwt.ParseWithClaims(str, claims, func(token_ *gojwt.Token) (interface{}, error) { + parsed, err := gojwt.ParseWithClaims(str, claims, func(_ *gojwt.Token) (interface{}, error) { principal, err = a.principalStore.Find(ctx, claims.PrincipalID) if err != nil { return nil, fmt.Errorf("failed to get principal for token: %w", err) diff --git a/app/router/git.go b/app/router/git.go index cf45517be..f1398bbbc 100644 --- a/app/router/git.go +++ b/app/router/git.go @@ -96,7 +96,7 @@ func NewGitHandler( } func stubGitHandler() http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("Seems like an asteroid destroyed the ancient git protocol")) w.WriteHeader(http.StatusBadGateway) } diff --git a/app/router/web.go b/app/router/web.go index 7646514dc..237608259 100644 --- a/app/router/web.go +++ b/app/router/web.go @@ -63,7 +63,7 @@ func NewWebHandler(config *types.Config, // openapi playground endpoints // TODO: this should not be generated and marshaled on the fly every time? - r.HandleFunc("/openapi.yaml", func(w http.ResponseWriter, r *http.Request) { + r.HandleFunc("/openapi.yaml", func(w http.ResponseWriter, _ *http.Request) { spec := openapi.Generate() data, err := spec.MarshalYAML() if err != nil { diff --git a/app/sse/sse.go b/app/sse/sse.go index 2e94390af..08ee492dc 100644 --- a/app/sse/sse.go +++ b/app/sse/sse.go @@ -96,7 +96,7 @@ func (e *pubsubStreamer) Stream( namespaceOption := pubsub.WithChannelNamespace(e.namespace) topic := getSpaceTopic(spaceID) consumer := e.pubsub.Subscribe(ctx, topic, g, namespaceOption) - cleanupFN := func(ctx context.Context) error { + cleanupFN := func(_ context.Context) error { return consumer.Close() } diff --git a/events/wire.go b/events/wire.go index 4f4fa2b22..c1912216e 100644 --- a/events/wire.go +++ b/events/wire.go @@ -77,7 +77,7 @@ func provideSystemRedis(config Config, redisClient redis.UniversalClient) (*Syst } func newMemoryStreamConsumerFactoryMethod(broker *stream.MemoryBroker, namespace string) StreamConsumerFactoryFunc { - return func(groupName string, consumerName string) (StreamConsumer, error) { + return func(groupName string, _ string) (StreamConsumer, error) { return stream.NewMemoryConsumer(broker, namespace, groupName) } } diff --git a/lock/memory.go b/lock/memory.go index 61bb807aa..d5eba7c56 100644 --- a/lock/memory.go +++ b/lock/memory.go @@ -52,7 +52,7 @@ func (m *InMemory) NewMutex(key string, options ...Option) (Mutex, error) { // set default delayFunc if config.DelayFunc == nil { - config.DelayFunc = func(i int) time.Duration { + config.DelayFunc = func(_ int) time.Duration { return config.RetryDelay } } diff --git a/lock/options.go b/lock/options.go index 969b2829e..400dadb0c 100644 --- a/lock/options.go +++ b/lock/options.go @@ -55,7 +55,7 @@ func WithTries(tries int) Option { // WithRetryDelay can be used to set the amount of time to wait between retries. func WithRetryDelay(delay time.Duration) Option { return OptionFunc(func(m *Config) { - m.DelayFunc = func(tries int) time.Duration { + m.DelayFunc = func(_ int) time.Duration { return delay } }) diff --git a/store/database/dbtx/runner_test.go b/store/database/dbtx/runner_test.go index ff401782a..dc4c822aa 100644 --- a/store/database/dbtx/runner_test.go +++ b/store/database/dbtx/runner_test.go @@ -275,7 +275,7 @@ func TestLocking(t *testing.T) { for _, test := range tests { l := &lockerCounter{} - t.Run(test.name, func(t *testing.T) { + t.Run(test.name, func(_ *testing.T) { test.fn(runnerDB{ db: dbMockNop{}, mx: l,