Skip to content

Commit a16d1ed

Browse files
update dependencies and workflows (#14)
1 parent 865a92b commit a16d1ed

File tree

8 files changed

+64
-57
lines changed

8 files changed

+64
-57
lines changed

.github/workflows/generate-tag.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
1313
steps:
1414
- name: Check out code
15-
uses: actions/checkout@master
15+
uses: actions/checkout@v4
1616
with:
1717
fetch-depth: '0'
1818

1919
- name: Checkout github-tag-action
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
with:
2222
repository: ${{ vars.GENERATE_TAG_REPO || 'anothrNick/github-tag-action' }}
2323
ref: ${{ vars.GENERATE_TAG_REF || '1.62.0' }}

.github/workflows/go.yml

+16-10
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,31 @@ jobs:
1515
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
1616
steps:
1717
- name: Set up Go
18-
uses: actions/setup-go@v3
18+
uses: actions/setup-go@v5
1919
with:
20-
go-version: 1.19
20+
go-version: 1.22
21+
check-latest: true
22+
cache: false
2123

2224
- name: Check out code into the Go module directory
23-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2426

2527
- name: Run golangci-lint
26-
uses: golangci/golangci-lint-action@v3
28+
uses: golangci/golangci-lint-action@v6
2729

2830
build:
2931
name: Build
3032
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
3133
steps:
3234
- name: Set up Go
33-
uses: actions/setup-go@v3
35+
uses: actions/setup-go@v5
3436
with:
35-
go-version: 1.19
37+
go-version: 1.22
38+
check-latest: true
39+
cache: false
3640

3741
- name: Check out code into the Go module directory
38-
uses: actions/checkout@v3
42+
uses: actions/checkout@v4
3943

4044
- name: Build
4145
run: make build
@@ -45,12 +49,14 @@ jobs:
4549
runs-on: ${{ vars.RUNNER_UBUNTU && fromJSON(vars.RUNNER_UBUNTU) || 'ubuntu-latest' }}
4650
steps:
4751
- name: Set up Go
48-
uses: actions/setup-go@v3
52+
uses: actions/setup-go@v5
4953
with:
50-
go-version: 1.19
54+
go-version: 1.22
55+
check-latest: true
56+
cache: false
5157

5258
- name: Check out code into the Go module directory
53-
uses: actions/checkout@v3
59+
uses: actions/checkout@v4
5460

5561
- name: Run tests
5662
run: make test

.golangci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ linters-settings:
22
errcheck:
33
check-blank: true
44
govet:
5-
check-shadowing: true
5+
shadowing: true
66
revive:
77
min-confidence: 0
88
dupl:
@@ -25,7 +25,7 @@ linters:
2525
disable-all: true
2626
enable:
2727
- bodyclose
28-
- depguard
28+
# - depguard
2929
- dogsled
3030
- dupl
3131
- errcheck
@@ -50,7 +50,7 @@ linters:
5050
- misspell
5151
- nakedret
5252
- prealloc
53-
- exportloopref
53+
- copyloopvar
5454

5555
- staticcheck
5656
- stylecheck

cmd/test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,13 @@ func loadTestGrammar() parser.Parsers {
9494
return wbnf.MustCompile(string(text), makeResolver(inGrammarFile))
9595
}
9696

97-
func testWbnfFile(filename, grammar string) error {
97+
func testWbnfFile(filename, grammar string) {
9898
g := wbnf.MustCompile(grammar, makeResolver(filename))
9999
if printTree {
100100
fmt.Println(ast.BuildTreeView("grammar", g.Node().(wbnf.GrammarNode).Node, true))
101101
} else {
102102
fmt.Println(g.Node().(ast.Node))
103103
}
104-
105-
return nil
106104
}
107105

108106
func test(c *cli.Context) error {
@@ -131,7 +129,9 @@ func test(c *cli.Context) error {
131129
input = string(buf)
132130
}
133131
if inGrammarFile == "" {
134-
return testWbnfFile(source, input)
132+
testWbnfFile(source, input)
133+
134+
return nil
135135
}
136136
g := loadTestGrammar()
137137

go.mod

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ module github.com/arr-ai/wbnf
33
go 1.18
44

55
require (
6-
github.com/arr-ai/frozen v0.20.1
7-
github.com/iancoleman/strcase v0.2.0
8-
github.com/sirupsen/logrus v1.9.0
9-
github.com/stretchr/testify v1.8.0
10-
github.com/urfave/cli v1.22.10
6+
github.com/arr-ai/frozen v0.20.3
7+
github.com/iancoleman/strcase v0.3.0
8+
github.com/sirupsen/logrus v1.9.3
9+
github.com/stretchr/testify v1.9.0
10+
github.com/urfave/cli v1.22.15
1111
)
1212

1313
require (
14-
github.com/arr-ai/hash v0.8.0 // indirect
15-
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
14+
github.com/arr-ai/hash v1.1.0 // indirect
15+
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
1616
github.com/davecgh/go-spew v1.1.1 // indirect
1717
github.com/go-errors/errors v1.4.2 // indirect
1818
github.com/kr/text v0.2.0 // indirect
1919
github.com/pmezard/go-difflib v1.0.0 // indirect
2020
github.com/russross/blackfriday/v2 v2.1.0 // indirect
21-
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 // indirect
21+
golang.org/x/sys v0.13.0 // indirect
2222
gopkg.in/yaml.v3 v3.0.1 // indirect
2323
)

go.sum

+21-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parser/scanner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s Scanner) Format(state fmt.State, c rune) {
6464
if c == 'q' {
6565
_, _ = fmt.Fprintf(state, "%q", s.slice())
6666
} else {
67-
_, _ = state.Write([]byte(s.slice()))
67+
_, _ = state.Write([]byte(s.slice())) //nolint:errcheck
6868
}
6969
}
7070

wbnf/compile.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,28 @@ func parseString(s string) string {
3636
if err != nil {
3737
panic(err)
3838
}
39-
sb.WriteByte(uint8(n))
39+
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
4040
i++
4141
case 'u':
4242
n, err := strconv.ParseInt(s[i:i+4], 16, 16)
4343
if err != nil {
4444
panic(err)
4545
}
46-
sb.WriteByte(uint8(n))
46+
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
4747
i += 2
4848
case 'U':
4949
n, err := strconv.ParseInt(s[i:i+8], 16, 32)
5050
if err != nil {
5151
panic(err)
5252
}
53-
sb.WriteByte(uint8(n))
53+
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
5454
i += 4
5555
case '0', '1', '2', '3', '4', '5', '6', '7':
5656
n, err := strconv.ParseInt(s[i:i+3], 8, 8)
5757
if err != nil {
5858
panic(err)
5959
}
60-
sb.WriteByte(uint8(n))
60+
sb.WriteByte(uint8(n)) // nolint:gosec // G115: integer overflow conversion int64 -> uint8
6161
i++
6262
case 'a':
6363
sb.WriteByte('\a')
@@ -176,23 +176,23 @@ func (gb grammarBuilder) buildQuant(q QuantNode, term parser.Term) parser.Term {
176176
return parser.Some(term)
177177
}
178178
case 1:
179-
min := 0
180-
max := 0
179+
mn := 0
180+
mx := 0
181181
if x := q.OneMin().String(); x != "" {
182182
val, err := strconv.Atoi(x)
183183
if err != nil {
184184
panic(err)
185185
}
186-
min = val
186+
mn = val
187187
}
188188
if x := q.OneMax().String(); x != "" {
189189
val, err := strconv.Atoi(x)
190190
if err != nil {
191191
panic(err)
192192
}
193-
max = val
193+
mx = val
194194
}
195-
return parser.Quant{Term: term, Min: min, Max: max}
195+
return parser.Quant{Term: term, Min: mn, Max: mx}
196196
case 2:
197197
assoc := parser.NewAssociativity(q.OneOp())
198198
sep := gb.buildNamed(*q.OneNamed())

0 commit comments

Comments
 (0)