fix lint errors (#1034)

pull/3484/head
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.
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 == "" {

View File

@ -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")
}
}

View File

@ -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)

View File

@ -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)
},
},

View File

@ -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)

View File

@ -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)
}

View File

@ -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 {

View File

@ -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()
}

View File

@ -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)
}
}

View File

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

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.
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
}
})

View File

@ -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,