Skip to content

Commit

Permalink
remove named return
Browse files Browse the repository at this point in the history
  • Loading branch information
buixor committed Mar 13, 2024
1 parent d094c83 commit 680b9c9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
10 changes: 5 additions & 5 deletions pkg/appsec/query_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
)

// parseQuery and parseQuery are copied net/url package, but allow semicolon in values
func ParseQuery(query string) (url.Values, error) {
func ParseQuery(query string) url.Values {
m := make(url.Values)
err := parseQuery(m, query)
return m, err
parseQuery(m, query)
return m
}

func parseQuery(m url.Values, query string) (err error) {
func parseQuery(m url.Values, query string) {
for query != "" {
var key string
key, query, _ = strings.Cut(query, "&")
Expand All @@ -28,7 +28,7 @@ func parseQuery(m url.Values, query string) (err error) {
value = unescape(value)
m[key] = append(m[key], value)
}
return err
return

Check failure on line 31 in pkg/appsec/query_utils.go

View workflow job for this annotation

GitHub Actions / Build + tests

S1023: redundant `return` statement (gosimple)

Check failure on line 31 in pkg/appsec/query_utils.go

View workflow job for this annotation

GitHub Actions / Build + tests

S1023: redundant `return` statement (gosimple)
}

func hexDigitToByte(digit byte) (byte, bool) {
Expand Down
5 changes: 1 addition & 4 deletions pkg/appsec/query_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ func TestParseQuery(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
res, err := ParseQuery(test.query)
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
res := ParseQuery(test.query)
if !reflect.DeepEqual(res, test.expected) {
t.Fatalf("unexpected result: %v", res)
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/appsec/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,6 @@ func NewParsedRequestFromRequest(r *http.Request, logger *logrus.Entry) (ParsedR
}
}

parsed_args, err := ParseQuery(parsedURL.RawQuery)
if err != nil {
logger.Debugf("While parsing query %s : %s", parsedURL.RawQuery, err)
}

return ParsedRequest{
RemoteAddr: r.RemoteAddr,
UUID: uuid.New().String(),
Expand All @@ -372,7 +367,7 @@ func NewParsedRequestFromRequest(r *http.Request, logger *logrus.Entry) (ParsedR
URL: r.URL,
Proto: r.Proto,
Body: body,
Args: parsed_args,
Args: ParseQuery(parsedURL.RawQuery),
TransferEncoding: r.TransferEncoding,
ResponseChannel: make(chan AppsecTempResponse),
RemoteAddrNormalized: remoteAddrNormalized,
Expand Down

0 comments on commit 680b9c9

Please sign in to comment.