Skip to content

Commit 86f47b0

Browse files
committed
Upgrade to golangci-lint 2.10.0 and fix issues
1 parent 7892f09 commit 86f47b0

7 files changed

Lines changed: 13 additions & 11 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ brew-lint-depends:
4747

4848
.PHONY: debian-lint-depends # Install linting tools on Debian
4949
debian-lint-depends:
50-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v2.5.0
50+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v2.10.1
5151

5252
.PHONY: install-generators # Install Go code generators
5353
install-generators:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ A brief overview of [RFC 9535 JSONPath] syntax:
3535

3636
## Dependencies
3737

38-
This package has no runtime dependencies, only testing dependencies.
38+
This package has only test dependencies.
3939

4040
## Copyright
4141

parser/lex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (lex *lexer) skipBlankSpace() rune {
213213

214214
// isBlankSpace returns true if r is blank space.
215215
func isBlankSpace(r rune) bool {
216-
return blanks&(1<<uint64(r)) != 0
216+
return r >= 0 && blanks&(1<<r) != 0
217217
}
218218

219219
// peekPastBlankSpace returns the next non-blank space rune from the current

parser/lex_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:revive
12
package parser
23

34
import (

path_example_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,17 @@ func ExampleParser() {
190190
parser := jsonpath.NewParser()
191191

192192
// Parse a list of paths.
193-
paths := []*jsonpath.Path{}
194-
for _, path := range []string{
193+
strings := []string{
195194
"$.store.book[*].author",
196195
"$..author",
197196
"$.store..color",
198197
"$..book[2].author",
199198
"$..book[2].publisher",
200199
"$..book[?@.isbn].title",
201200
"$..book[?@.price<10].title",
202-
} {
201+
}
202+
paths := make([]*jsonpath.Path, 0, len(strings))
203+
for _, path := range strings {
203204
p, err := parser.Parse(path)
204205
if err != nil {
205206
log.Fatal(err)

spec/function.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ func (fe *FuncExpr) String() string {
540540
// [FuncExprArg] in fe (as passed to [Function]) and passing them to fe's
541541
// [FuncExtension].
542542
func (fe *FuncExpr) evaluate(current, root any) PathValue {
543-
res := []PathValue{}
544-
for _, a := range fe.args {
545-
res = append(res, a.evaluate(current, root))
543+
res := make([]PathValue, len(fe.args))
544+
for i, a := range fe.args {
545+
res[i] = a.evaluate(current, root)
546546
}
547547

548548
return fe.fn.Evaluate(res)

spec/query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (q *PathQuery) Select(current, root any) []any {
5252
res[0] = root
5353
}
5454
for _, seg := range q.segments {
55-
segRes := []any{}
55+
segRes := make([]any, 0, len(res))
5656
for _, v := range res {
5757
segRes = append(segRes, seg.Select(v, root)...)
5858
}
@@ -73,7 +73,7 @@ func (q *PathQuery) SelectLocated(current, root any, parent NormalizedPath) []*L
7373
res[0] = newLocatedNode(parent, current)
7474
}
7575
for _, seg := range q.segments {
76-
segRes := []*LocatedNode{}
76+
segRes := make([]*LocatedNode, 0, len(res))
7777
for _, v := range res {
7878
segRes = append(segRes, seg.SelectLocated(v.Node, root, v.Path)...)
7979
}

0 commit comments

Comments
 (0)