Skip to content

Commit 87dc886

Browse files
committed
Test TinyGo on 1.24 and update golangci-lint
Restore testing TinyGo on Go v1.24, as recent releases support it. Also upgrade `golangci-lint` to 2.1.5, which requires a new config file format, and fix the issues it identifies.
1 parent 6ad57cb commit 87dc886

File tree

8 files changed

+78
-138
lines changed

8 files changed

+78
-138
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ jobs:
2121
run: make test
2222
- name: Setup TinyGo
2323
uses: acifani/setup-tinygo@v2
24-
with: { tinygo-version: 0.34.0 }
24+
with: { tinygo-version: 0.37.0 }
2525
- name: Test WASM
2626
run: make wasm
27-
if: matrix.go != '1.24'
2827
lint:
2928
name: 📊 Lint and Cover
3029
runs-on: ubuntu-latest

.golangci.yaml

Lines changed: 64 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,71 @@
1-
# Options for analysis running.
2-
run:
3-
# Timeout for analysis, e.g. 30s, 5m.
4-
# Default: 1m
5-
timeout: 5m
6-
# Which dirs to skip: issues from them won't be reported.
7-
# Can use regexp here: `generated.*`, regexp is applied on full path,
8-
# including the path prefix if one is set.
9-
# Default value is empty list,
10-
# but default dirs are skipped independently of this option's value (see skip-dirs-use-default).
11-
# "/" will be replaced by current OS file path separator to properly work on Windows.
12-
# skip-dirs: []
13-
# Which files to skip: they will be analyzed, but issues from them won't be reported.
14-
# Default value is empty list,
15-
# but there is no need to include all autogenerated files,
16-
# we confidently recognize autogenerated files.
17-
# If it's not please let us know.
18-
# "/" will be replaced by current OS file path separator to properly work on Windows.
19-
# skip-files: []
20-
21-
# output configuration options
22-
# output:
23-
# Format: colored-line-number|line-number|json|colored-tab|tab|checkstyle|code-climate|junit-xml|github-actions|teamcity
24-
#
25-
# Multiple can be specified by separating them by comma, output can be provided
26-
# for each of them by separating format name and path by colon symbol.
27-
# Output path can be either `stdout`, `stderr` or path to the file to write to.
28-
# Example: "checkstyle:report.xml,json:stdout,colored-line-number"
29-
#
30-
# Default: colored-line-number
31-
# formats: colored-line-number
32-
33-
# Re-enable excluded linters. Restores missing documentation checks, among
34-
# others.
35-
# https://golangci-lint.run/usage/false-positives/#default-exclusions
36-
# https://github.com/golangci/golangci-lint/issues/456#issuecomment-986837325
37-
issues:
38-
exclude-use-default: false
39-
exclude-rules:
40-
# Exclude some linters from running on tests files.
41-
- path: _test\.go
42-
linters:
43-
- funlen
44-
- goerr113
45-
- err113
46-
- wrapcheck
47-
- maintidx
48-
- path: registry/funcs\.go
49-
linters:
50-
- err113
51-
1+
version: "2"
522
linters:
53-
# Enable specific linter
54-
# https://golangci-lint.run/usage/linters/#enabled-by-default
55-
# enable: []
56-
57-
# Enable all available linters.
58-
# Default: false
59-
enable-all: true
60-
61-
# Disable specific linter
62-
# https://golangci-lint.run/usage/linters/#disabled-by-default
3+
default: all
634
disable:
64-
# Deprecated
65-
- exportloopref # Replaced by copyloopvar
66-
675
# Too strict.
6+
- cyclop # redundant, covered by gocyclo
687
- depguard
69-
- testpackage
70-
- varnamelen
718
- exhaustruct
72-
- cyclop # redundant, covered by gocyclo
9+
- funcorder # new, too much to move around
10+
- nestif # redundant, covered by gocyclo
7311
- nlreturn
12+
- testpackage
13+
- varnamelen
7414
- wsl
75-
- nestif # redundant, covered by gocyclo
76-
77-
# Enable presets.
78-
# https://golangci-lint.run/usage/linters
79-
presets: []
80-
81-
# Run only fast linters from enabled linters set (first run won't be fast)
82-
# Default: false
83-
# fast: true
84-
85-
linters-settings:
86-
errcheck:
87-
check-type-assertions: false
88-
check-blank: false
89-
disable-default-exclusions: false
90-
exclude-functions:
91-
- fmt.Fprintf
92-
- fmt.Fprintln
93-
- fmt.Fprint
94-
funlen:
95-
# Ignore comments when counting lines.
96-
ignore-comments: true
97-
exhaustive:
98-
default-signifies-exhaustive: true
99-
ireturn:
100-
# ireturn does not allow using `allow` and `reject` settings at the same time.
101-
# Both settings are lists of the keywords and regular expressions matched to interface or package names.
102-
# keywords:
103-
# - `empty` for `any`
104-
# - `error` for errors
105-
# - `stdlib` for standard library
106-
# - `anon` for anonymous interfaces
107-
# - `generic` for generic interfaces added in go 1.18
108-
109-
# By default, it allows using errors, empty interfaces, anonymous interfaces,
110-
# and interfaces provided by the standard library.
111-
allow:
112-
- anon
113-
- error
114-
- empty
115-
- stdlib
116-
- generic
117-
- spec\.JSONPathValue
118-
- spec\.FunctionExprArg
119-
- spec\.Selector
120-
- spec\.BasicExpr
121-
- spec\.CompVal
122-
# You can specify idiomatic endings for interface
123-
# - (or|er)$
124-
# reject-list of interfaces
125-
# reject:
126-
# - github.com\/user\/package\/v4\.Type
127-
dupword:
128-
ignore:
129-
- R.
15+
settings:
16+
dupword:
17+
ignore:
18+
- R.
19+
errcheck:
20+
disable-default-exclusions: false
21+
check-type-assertions: false
22+
check-blank: false
23+
exclude-functions:
24+
- fmt.Fprintf
25+
- fmt.Fprintln
26+
- fmt.Fprint
27+
exhaustive:
28+
default-signifies-exhaustive: true
29+
funlen:
30+
ignore-comments: true
31+
ireturn:
32+
allow:
33+
- anon
34+
- error
35+
- empty
36+
- stdlib
37+
- generic
38+
- spec\.JSONPathValue
39+
- spec\.FunctionExprArg
40+
- spec\.Selector
41+
- spec\.BasicExpr
42+
- spec\.CompVal
43+
exclusions:
44+
generated: lax
45+
rules:
46+
# Exclude some linters from running on tests files.
47+
- linters:
48+
- err113
49+
- funlen
50+
- maintidx
51+
- wrapcheck
52+
path: _test\.go
53+
- linters:
54+
- err113
55+
path: registry/funcs\.go
56+
paths:
57+
- third_party$
58+
- builtin$
59+
- examples$
60+
formatters:
61+
enable:
62+
- gci
63+
- gofmt
64+
- gofumpt
65+
- goimports
66+
exclusions:
67+
generated: lax
68+
paths:
69+
- third_party$
70+
- builtin$
71+
- examples$

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ All notable changes to this project will be documented in this file. It uses the
1414
* Fixed the panic messages from `spec.Slice` to properly report coming from
1515
`Slice` and not `NewSlice`.
1616

17+
### 📔 Notes
18+
19+
* Upgraded to and fixed issues reported by `golangci-lint` v2.1.5.
20+
* Added TinyGo testing on Go v1.24.
21+
1722
[v0.4.1]: https://github.com/theory/jsonpath/compare/v0.4.0...v0.4.1
1823

1924
## [v0.4.0] — 2025-01-15

Makefile

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

3939
.PHONY: debian-lint-depends # Install linting tools on Debian
4040
debian-lint-depends:
41-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v1.63.4
41+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v2.1.5
4242

4343
.PHONY: install-generators # Install Go code generators
4444
install-generators:

parser/parse.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,7 @@ func (p *parser) parseLogicalOrExpr() (spec.LogicalOr, error) {
304304

305305
ands = append(ands, land)
306306
lex.scanBlankSpace()
307-
for {
308-
if lex.r != '|' {
309-
break
310-
}
307+
for lex.r == '|' {
311308
lex.scan()
312309
next := lex.scan()
313310
if next.tok != '|' {
@@ -334,10 +331,7 @@ func (p *parser) parseLogicalAndExpr() (spec.LogicalAnd, error) {
334331
ors := []spec.BasicExpr{expr}
335332
lex := p.lex
336333
lex.scanBlankSpace()
337-
for {
338-
if lex.r != '&' {
339-
break
340-
}
334+
for lex.r == '&' {
341335
lex.scan()
342336
next := lex.scan()
343337
if next.tok != '&' {

spec/filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (e *ExistExpr) testFilter(current, root any) bool {
131131

132132
// writeTo writes a string representation of e to buf.
133133
func (e *ExistExpr) writeTo(buf *strings.Builder) {
134-
buf.WriteString(e.PathQuery.String())
134+
buf.WriteString(e.String())
135135
}
136136

137137
// NonExistExpr represents a nonexistence expression.
@@ -147,7 +147,7 @@ func Nonexistence(q *PathQuery) *NonExistExpr {
147147
// writeTo writes a string representation of ne to buf.
148148
func (ne NonExistExpr) writeTo(buf *strings.Builder) {
149149
buf.WriteRune('!')
150-
buf.WriteString(ne.PathQuery.String())
150+
buf.WriteString(ne.String())
151151
}
152152

153153
// testFilter returns true if ne.Query selects no results from current or

spec/function.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ func (fq *FilterQueryExpr) ResultType() FuncType {
358358

359359
// writeTo writes a string representation of fq to buf.
360360
func (fq *FilterQueryExpr) writeTo(buf *strings.Builder) {
361-
buf.WriteString(fq.PathQuery.String())
361+
buf.WriteString(fq.String())
362362
}
363363

364364
// FunctionExpr represents a function expression, consisting of a named

spec/selector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (n Name) writeNormalizedTo(buf *strings.Builder) {
101101
buf.WriteString(`\\`)
102102
case '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x0b', '\x0e', '\x0f':
103103
// "00"-"07", "0b", "0e"-"0f"
104-
buf.WriteString(fmt.Sprintf(`\u000%x`, r))
104+
fmt.Fprintf(buf, `\u000%x`, r)
105105
default:
106106
buf.WriteRune(r)
107107
}
@@ -493,7 +493,7 @@ func (f *FilterSelector) SelectLocated(current, root any, parent NormalizedPath)
493493
// [Select] as it iterates over nodes, and always passes the root value($) for
494494
// filter expressions that reference it.
495495
func (f *FilterSelector) Eval(node, root any) bool {
496-
return f.LogicalOr.testFilter(node, root)
496+
return f.testFilter(node, root)
497497
}
498498

499499
// isSingular returns false because Filters can return more than one value.

0 commit comments

Comments
 (0)