Skip to content

Commit

Permalink
fix incorrect usage of NewSortingError (#33)
Browse files Browse the repository at this point in the history
The error message was correct nonetheless, but there is no need to call
`fmt.Sprintf` as this is done inside `sorting.NewSortingError`

## Why

The linter was unhappy (for good reasons). But it is just a refactor,
the original code returned the desired value.
  • Loading branch information
mgoetzegb authored Sep 3, 2024
1 parent c6f8fe8 commit 6c7477f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/web/helper/parameter_parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ package helper

import (
"fmt"
"strings"

"github.com/gin-gonic/gin"
"github.com/greenbone/opensight-notification-service/pkg/errs"
"strings"

"github.com/greenbone/opensight-golang-libraries/pkg/query"
"github.com/greenbone/opensight-golang-libraries/pkg/query/filter"
Expand Down Expand Up @@ -101,8 +102,8 @@ func validateSorting(sortingRequest *sorting.Request, allowedSortFields []string
}

if !lo.Contains(allowedSortFields, sortingRequest.SortColumn) {
return sorting.NewSortingError(fmt.Sprintf("%s is no valid sort column, possible values: %s",
sortingRequest.SortColumn, strings.Join(allowedSortFields, ", ")))
return sorting.NewSortingError("%s is no valid sort column, possible values: %s",
sortingRequest.SortColumn, strings.Join(allowedSortFields, ", "))
}

return nil
Expand Down

0 comments on commit 6c7477f

Please sign in to comment.