fix lint errors (#1034)

This commit is contained in:
Atefeh Mohseni-Ejiyeh 2024-02-09 01:15:15 +00:00 committed by Harness
parent d96afd89bd
commit a937793edb
12 changed files with 19 additions and 19 deletions

View File

@ -50,7 +50,7 @@ var matcherCheckIdentifier = regexp.MustCompile(regexpCheckIdentifier)
// Sanitize validates and sanitizes the ReportInput data. // Sanitize validates and sanitizes the ReportInput data.
func (in *ReportInput) Sanitize( 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 { ) error {
// TODO [CODE-1363]: remove after identifier migration. // TODO [CODE-1363]: remove after identifier migration.
if in.Identifier == "" { if in.Identifier == "" {

View File

@ -35,8 +35,8 @@ func ProvideCheckSanitizers() map[enum.CheckPayloadKind]func(in *ReportInput, s
return registeredCheckSanitizers return registeredCheckSanitizers
} }
func createEmptyPayloadSanitizer() func(in *ReportInput, s *auth.Session) error { func createEmptyPayloadSanitizer() func(in *ReportInput, _ *auth.Session) error {
return func(in *ReportInput, s *auth.Session) error { return func(in *ReportInput, _ *auth.Session) error {
// the default payload kind (empty) does not support the payload data: clear it here // the default payload kind (empty) does not support the payload data: clear it here
in.Payload.Version = "" in.Payload.Version = ""
in.Payload.Data = []byte("{}") 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 { func createRawPayloadSanitizer() func(in *ReportInput, _ *auth.Session) error {
return func(in *ReportInput, s *auth.Session) error { return func(in *ReportInput, _ *auth.Session) error {
// the text payload kinds (raw and markdown) do not support the version // the text payload kinds (raw and markdown) do not support the version
if in.Payload.Version != "" { if in.Payload.Version != "" {
return usererror.BadRequestf("Payload version must be empty for the payload kind '%s'", 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 { func createPipelinePayloadSanitizer() func(in *ReportInput, _ *auth.Session) error {
return func(in *ReportInput, s *auth.Session) error { return func(_ *ReportInput, _ *auth.Session) error {
return usererror.BadRequest("Kind cannot be pipeline for external checks") return usererror.BadRequest("Kind cannot be pipeline for external checks")
} }
} }

View File

@ -22,7 +22,7 @@ import (
) )
func HandleGitIgnore() http.HandlerFunc { func HandleGitIgnore() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, _ *http.Request) {
files, err := resources.GitIgnores() files, err := resources.GitIgnores()
if err != nil { if err != nil {
render.ErrorMessagef(w, http.StatusInternalServerError, "error loading gitignore files: %v", err) render.ErrorMessagef(w, http.StatusInternalServerError, "error loading gitignore files: %v", err)
@ -33,7 +33,7 @@ func HandleGitIgnore() http.HandlerFunc {
} }
func HandleLicence() 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() response, err := resources.Licenses()
if err != nil { if err != nil {
render.ErrorMessagef(w, http.StatusInternalServerError, "error loading licence file: %v", err) render.ErrorMessagef(w, http.StatusInternalServerError, "error loading licence file: %v", err)

View File

@ -185,7 +185,7 @@ func TestJSONArrayDynamic(t *testing.T) {
name: "happy path", name: "happy path",
args: args[*mock]{ args: args[*mock]{
ctx: noctx, ctx: noctx,
f: func(ch chan<- *mock, cherr chan<- error) { f: func(ch chan<- *mock, _ chan<- error) {
defer close(ch) defer close(ch)
ch <- &mock{ID: 1} ch <- &mock{ID: 1}
}, },
@ -197,7 +197,7 @@ func TestJSONArrayDynamic(t *testing.T) {
name: "empty array response", name: "empty array response",
args: args[*mock]{ args: args[*mock]{
ctx: noctx, ctx: noctx,
f: func(ch chan<- *mock, cherr chan<- error) { f: func(ch chan<- *mock, _ chan<- error) {
close(ch) close(ch)
}, },
}, },

View File

@ -62,7 +62,7 @@ func (a *JWTAuthenticator) Authenticate(r *http.Request) (*auth.Session, error)
var principal *types.Principal var principal *types.Principal
var err error var err error
claims := &jwt.Claims{} 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) principal, err = a.principalStore.Find(ctx, claims.PrincipalID)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get principal for token: %w", err) return nil, fmt.Errorf("failed to get principal for token: %w", err)

View File

@ -96,7 +96,7 @@ func NewGitHandler(
} }
func stubGitHandler() http.HandlerFunc { 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.Write([]byte("Seems like an asteroid destroyed the ancient git protocol"))
w.WriteHeader(http.StatusBadGateway) w.WriteHeader(http.StatusBadGateway)
} }

View File

@ -63,7 +63,7 @@ func NewWebHandler(config *types.Config,
// openapi playground endpoints // openapi playground endpoints
// TODO: this should not be generated and marshaled on the fly every time? // 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() spec := openapi.Generate()
data, err := spec.MarshalYAML() data, err := spec.MarshalYAML()
if err != nil { if err != nil {

View File

@ -96,7 +96,7 @@ func (e *pubsubStreamer) Stream(
namespaceOption := pubsub.WithChannelNamespace(e.namespace) namespaceOption := pubsub.WithChannelNamespace(e.namespace)
topic := getSpaceTopic(spaceID) topic := getSpaceTopic(spaceID)
consumer := e.pubsub.Subscribe(ctx, topic, g, namespaceOption) consumer := e.pubsub.Subscribe(ctx, topic, g, namespaceOption)
cleanupFN := func(ctx context.Context) error { cleanupFN := func(_ context.Context) error {
return consumer.Close() return consumer.Close()
} }

View File

@ -77,7 +77,7 @@ func provideSystemRedis(config Config, redisClient redis.UniversalClient) (*Syst
} }
func newMemoryStreamConsumerFactoryMethod(broker *stream.MemoryBroker, namespace string) StreamConsumerFactoryFunc { 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) return stream.NewMemoryConsumer(broker, namespace, groupName)
} }
} }

View File

@ -52,7 +52,7 @@ func (m *InMemory) NewMutex(key string, options ...Option) (Mutex, error) {
// set default delayFunc // set default delayFunc
if config.DelayFunc == nil { if config.DelayFunc == nil {
config.DelayFunc = func(i int) time.Duration { config.DelayFunc = func(_ int) time.Duration {
return config.RetryDelay return config.RetryDelay
} }
} }

View File

@ -55,7 +55,7 @@ func WithTries(tries int) Option {
// WithRetryDelay can be used to set the amount of time to wait between retries. // WithRetryDelay can be used to set the amount of time to wait between retries.
func WithRetryDelay(delay time.Duration) Option { func WithRetryDelay(delay time.Duration) Option {
return OptionFunc(func(m *Config) { return OptionFunc(func(m *Config) {
m.DelayFunc = func(tries int) time.Duration { m.DelayFunc = func(_ int) time.Duration {
return delay return delay
} }
}) })

View File

@ -275,7 +275,7 @@ func TestLocking(t *testing.T) {
for _, test := range tests { for _, test := range tests {
l := &lockerCounter{} l := &lockerCounter{}
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(_ *testing.T) {
test.fn(runnerDB{ test.fn(runnerDB{
db: dbMockNop{}, db: dbMockNop{},
mx: l, mx: l,