Skip to content

Commit

Permalink
Avoid bare returns (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
trishankatdatadog authored May 23, 2024
1 parent 2a9d2e5 commit a27281e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions verifier/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,21 @@ func matchChunk(chunk, s string) (rest string, ok bool, err error) {
// getEsc gets a possibly-escaped character from chunk, for a character class.
func getEsc(chunk string) (r rune, nchunk string, err error) {
if len(chunk) == 0 || chunk[0] == '-' || chunk[0] == ']' {
err = errBadPattern
return
return 0, "", errBadPattern
}
if chunk[0] == '\\' {
chunk = chunk[1:]
if len(chunk) == 0 {
err = errBadPattern
return
return 0, "", errBadPattern
}
}
r, n := utf8.DecodeRuneInString(chunk)
if r == utf8.RuneError && n == 1 {
err = errBadPattern
return 0, "", errBadPattern
}
nchunk = chunk[n:]
if len(nchunk) == 0 {
err = errBadPattern
return 0, "", errBadPattern
}
return
return r, nchunk, nil
}

0 comments on commit a27281e

Please sign in to comment.