Skip to content

Commit

Permalink
chore: bump golanci-lint from 1.54 to 1.56 (#182)
Browse files Browse the repository at this point in the history
Signed-off-by: Yoan Blanc <[email protected]>
  • Loading branch information
greut authored Apr 2, 2024
1 parent 308412c commit a73573b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 #v4.0.0
with:
version: v1.54
version: v1.56
17 changes: 14 additions & 3 deletions fnmatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func FnmatchCase(pattern, name string) (bool, error) {
return r.MatchString(name), nil
}

func translate(pattern string) string { //nolint:funlen,gocognit,gocyclo,cyclop
func translate(pattern string) string { //nolint:funlen,gocognit,gocyclo,cyclop,maintidx
index := 0
pat := []rune(pattern)
length := len(pat)
Expand Down Expand Up @@ -60,6 +60,7 @@ func translate(pattern string) string { //nolint:funlen,gocognit,gocyclo,cyclop
p := index
if p < length && pat[p] == '*' {
result.WriteString(".*")

index++
} else {
result.WriteString(fmt.Sprintf("[^%s]*", pathSeparator))
Expand Down Expand Up @@ -87,32 +88,40 @@ func translate(pattern string) string { //nolint:funlen,gocognit,gocyclo,cyclop
if pat[p] == ']' && pat[p-1] != '\\' {
break
}

res.WriteRune(pat[p])

if pat[p] == '/' && pat[p-1] != '\\' {
hasSlash = true

break
}

p++
}

if hasSlash {
result.WriteString("\\[" + res.String())

index = p + 1
} else {
inBrackets = true
if index < length && pat[index] == '!' || pat[index] == '^' {
index++
result.WriteString("[^")

index++
} else {
result.WriteRune('[')
}

inBrackets = true
}
}
case ']':
if inBrackets && pat[index-2] == '\\' {
result.WriteString("\\]")
} else {
result.WriteRune(r)

inBrackets = false
}
case '{':
Expand All @@ -132,6 +141,7 @@ func translate(pattern string) string { //nolint:funlen,gocognit,gocyclo,cyclop

break
}

p++
}

Expand Down Expand Up @@ -163,6 +173,7 @@ func translate(pattern string) string { //nolint:funlen,gocognit,gocyclo,cyclop
index = p + 1
case matchesBraces:
result.WriteString("(?:")

braceLevel++
default:
result.WriteString("\\{")
Expand Down
1 change: 1 addition & 0 deletions fnmatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestTranslate(t *testing.T) {
test := test
t.Run(test.pattern, func(t *testing.T) {
t.Parallel()

result := translate(test.pattern)
if result != test.expected {
t.Errorf("%s != %s", test.expected, result)
Expand Down

0 comments on commit a73573b

Please sign in to comment.