mirror of
https://github.com/danog/liquid.git
synced 2024-11-30 07:38:59 +01:00
Replace gometalinter -> golangci; fix lint errors
This commit is contained in:
parent
26c51e4252
commit
42035af9b1
9
.golangci.yml
Normal file
9
.golangci.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
issues:
|
||||||
|
exclude-rules:
|
||||||
|
- linters: [gosimple]
|
||||||
|
path: values/drop_test.go # see the note in the file
|
||||||
|
text: "S1005:"
|
||||||
|
|
||||||
|
# go generate introduces these
|
||||||
|
- path: expressions/scanner.go
|
||||||
|
linters: [deadcode, unused, varcheck]
|
@ -21,7 +21,9 @@ Fork and clone the repo.
|
|||||||
Install package dependencies and development tools:
|
Install package dependencies and development tools:
|
||||||
|
|
||||||
* `make setup`
|
* `make setup`
|
||||||
* `go get -t ./...`
|
|
||||||
|
[Install golangci-lint](https://golangci-lint.run/usage/install/#local-installation).
|
||||||
|
On macOS: `brew install golangci-lint`
|
||||||
|
|
||||||
### Test and Lint
|
### Test and Lint
|
||||||
|
|
||||||
|
4
Makefile
4
Makefile
@ -24,7 +24,7 @@ imports: ## list imports
|
|||||||
@go list -f '{{join .Imports "\n"}}' ./... | grep -v `go list -f '{{.ImportPath}}'` | grep '\.' | sort | uniq
|
@go list -f '{{join .Imports "\n"}}' ./... | grep -v `go list -f '{{.ImportPath}}'` | grep '\.' | sort | uniq
|
||||||
|
|
||||||
lint: ## lint the package
|
lint: ## lint the package
|
||||||
gometalinter ./... --tests --deadline=5m --include=gofmt --exclude expressions/scanner.go --exclude y.go --exclude '.*_string.go' --disable=gotype --disable=interfacer
|
golangci-lint run
|
||||||
@echo lint passed
|
@echo lint passed
|
||||||
|
|
||||||
pre-commit: lint test ## lint and test the package
|
pre-commit: lint test ## lint and test the package
|
||||||
@ -33,8 +33,6 @@ setup: ## install dependencies and development tools
|
|||||||
go get golang.org/x/tools/cmd/stringer
|
go get golang.org/x/tools/cmd/stringer
|
||||||
go install golang.org/x/tools/cmd/goyacc
|
go install golang.org/x/tools/cmd/goyacc
|
||||||
go get -t ./...
|
go get -t ./...
|
||||||
go get github.com/alecthomas/gometalinter
|
|
||||||
gometalinter --install
|
|
||||||
|
|
||||||
test: ## test the package
|
test: ## test the package
|
||||||
go test ./...
|
go test ./...
|
||||||
|
@ -83,14 +83,19 @@ func BenchmarkEngine_Parse(b *testing.B) {
|
|||||||
engine := NewEngine()
|
engine := NewEngine()
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
io.WriteString(buf, `if{% if true %}true{% elsif %}elsif{% else %}else{% endif %}`)
|
_, err := io.WriteString(buf, `if{% if true %}true{% elsif %}elsif{% else %}else{% endif %}`)
|
||||||
io.WriteString(buf, `loop{% for item in array %}loop{% break %}{% endfor %}`)
|
require.NoError(b, err)
|
||||||
io.WriteString(buf, `case{% case value %}{% when a %}{% when b %{% endcase %}`)
|
_, err = io.WriteString(buf, `loop{% for item in array %}loop{% break %}{% endfor %}`)
|
||||||
io.WriteString(buf, `expr{{ a and b }}{{ a add: b }}`)
|
require.NoError(b, err)
|
||||||
|
_, err = io.WriteString(buf, `case{% case value %}{% when a %}{% when b %{% endcase %}`)
|
||||||
|
require.NoError(b, err)
|
||||||
|
_, err = io.WriteString(buf, `expr{{ a and b }}{{ a add: b }}`)
|
||||||
|
require.NoError(b, err)
|
||||||
}
|
}
|
||||||
s := buf.Bytes()
|
s := buf.Bytes()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
engine.ParseTemplate(s)
|
_, err := engine.ParseTemplate(s)
|
||||||
|
require.NoError(b, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
// This allows adding and removing references to fmt in the rules below,
|
// This allows adding and removing references to fmt in the rules below,
|
||||||
// without having to comment and un-comment the import statement above.
|
// without having to comment and un-comment the import statement above.
|
||||||
_ = fmt.Sprint("")
|
_ = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// Code generated by goyacc expressions.y. DO NOT EDIT.
|
||||||
|
|
||||||
//line expressions.y:2
|
//line expressions.y:2
|
||||||
package expressions
|
package expressions
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
// This allows adding and removing references to fmt in the rules below,
|
// This allows adding and removing references to fmt in the rules below,
|
||||||
// without having to comment and un-comment the import statement above.
|
// without having to comment and un-comment the import statement above.
|
||||||
_ = fmt.Sprint("")
|
_ = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
//line expressions.y:16
|
//line expressions.y:16
|
||||||
@ -84,6 +86,7 @@ var yyToknames = [...]string{
|
|||||||
"'['",
|
"'['",
|
||||||
"']'",
|
"']'",
|
||||||
}
|
}
|
||||||
|
|
||||||
var yyStatenames = [...]string{}
|
var yyStatenames = [...]string{}
|
||||||
|
|
||||||
const yyEofCode = 1
|
const yyEofCode = 1
|
||||||
@ -108,7 +111,6 @@ const yyPrivate = 57344
|
|||||||
const yyLast = 104
|
const yyLast = 104
|
||||||
|
|
||||||
var yyAct = [...]int{
|
var yyAct = [...]int{
|
||||||
|
|
||||||
9, 74, 46, 41, 8, 87, 78, 23, 14, 15,
|
9, 74, 46, 41, 8, 87, 78, 23, 14, 15,
|
||||||
18, 10, 11, 25, 42, 3, 4, 5, 6, 25,
|
18, 10, 11, 25, 42, 3, 4, 5, 6, 25,
|
||||||
37, 58, 10, 11, 40, 42, 45, 50, 51, 52,
|
37, 58, 10, 11, 40, 42, 45, 50, 51, 52,
|
||||||
@ -121,8 +123,8 @@ var yyAct = [...]int{
|
|||||||
85, 86, 83, 19, 34, 2, 1, 73, 20, 39,
|
85, 86, 83, 19, 34, 2, 1, 73, 20, 39,
|
||||||
17, 22, 67, 63,
|
17, 22, 67, 63,
|
||||||
}
|
}
|
||||||
var yyPact = [...]int{
|
|
||||||
|
|
||||||
|
var yyPact = [...]int{
|
||||||
7, -1000, 60, 76, 89, 71, 18, -1000, 19, 49,
|
7, -1000, 60, 76, 89, 71, 18, -1000, 19, 49,
|
||||||
-1000, -1000, 18, -1000, 18, 18, -6, 14, -3, -1000,
|
-1000, -1000, 18, -1000, 18, 18, -6, 14, -3, -1000,
|
||||||
10, 38, 1, 39, 83, -1000, 18, 18, 18, 18,
|
10, 38, 1, 39, 83, -1000, 18, 18, 18, 18,
|
||||||
@ -133,29 +135,29 @@ var yyPact = [...]int{
|
|||||||
-1000, -1000, -1000, 69, 20, -1000, -1000, -1000, 18, -1000,
|
-1000, -1000, -1000, 69, 20, -1000, -1000, -1000, 18, -1000,
|
||||||
88, 86, 6, -1000, -25, -1000, -1000, -1000,
|
88, 86, 6, -1000, -25, -1000, -1000, -1000,
|
||||||
}
|
}
|
||||||
var yyPgo = [...]int{
|
|
||||||
|
|
||||||
|
var yyPgo = [...]int{
|
||||||
0, 0, 71, 4, 94, 1, 103, 102, 101, 2,
|
0, 0, 71, 4, 94, 1, 103, 102, 101, 2,
|
||||||
100, 99, 3, 98, 97, 10, 96,
|
100, 99, 3, 98, 97, 10, 96,
|
||||||
}
|
}
|
||||||
var yyR1 = [...]int{
|
|
||||||
|
|
||||||
|
var yyR1 = [...]int{
|
||||||
0, 16, 16, 16, 16, 16, 10, 11, 11, 12,
|
0, 16, 16, 16, 16, 16, 10, 11, 11, 12,
|
||||||
12, 8, 9, 9, 15, 13, 6, 6, 5, 5,
|
12, 8, 9, 9, 15, 13, 6, 6, 5, 5,
|
||||||
14, 14, 14, 1, 1, 1, 1, 1, 3, 3,
|
14, 14, 14, 1, 1, 1, 1, 1, 3, 3,
|
||||||
3, 7, 7, 2, 2, 2, 2, 2, 2, 2,
|
3, 7, 7, 2, 2, 2, 2, 2, 2, 2,
|
||||||
2, 4, 4, 4,
|
2, 4, 4, 4,
|
||||||
}
|
}
|
||||||
var yyR2 = [...]int{
|
|
||||||
|
|
||||||
|
var yyR2 = [...]int{
|
||||||
0, 2, 5, 3, 3, 3, 2, 3, 1, 0,
|
0, 2, 5, 3, 3, 3, 2, 3, 1, 0,
|
||||||
3, 2, 0, 3, 1, 4, 5, 1, 1, 1,
|
3, 2, 0, 3, 1, 4, 5, 1, 1, 1,
|
||||||
0, 2, 3, 1, 1, 2, 4, 3, 1, 3,
|
0, 2, 3, 1, 1, 2, 4, 3, 1, 3,
|
||||||
4, 1, 3, 1, 3, 3, 3, 3, 3, 3,
|
4, 1, 3, 1, 3, 3, 3, 3, 3, 3,
|
||||||
3, 1, 3, 3,
|
3, 1, 3, 3,
|
||||||
}
|
}
|
||||||
var yyChk = [...]int{
|
|
||||||
|
|
||||||
|
var yyChk = [...]int{
|
||||||
-1000, -16, -4, 8, 9, 10, 11, -2, -3, -1,
|
-1000, -16, -4, 8, 9, 10, 11, -2, -3, -1,
|
||||||
4, 5, 29, 25, 17, 18, 5, -10, -15, 4,
|
4, 5, 29, 25, 17, 18, 5, -10, -15, 4,
|
||||||
-13, 5, -8, -1, 22, 7, 31, 12, 13, 24,
|
-13, 5, -8, -1, 22, 7, 31, 12, 13, 24,
|
||||||
@ -166,8 +168,8 @@ var yyChk = [...]int{
|
|||||||
25, -12, -12, -14, -5, 4, 5, -9, 28, 5,
|
25, -12, -12, -14, -5, 4, 5, -9, 28, 5,
|
||||||
6, 20, -1, 4, -5, 4, 5, 30,
|
6, 20, -1, 4, -5, 4, 5, 30,
|
||||||
}
|
}
|
||||||
var yyDef = [...]int{
|
|
||||||
|
|
||||||
|
var yyDef = [...]int{
|
||||||
0, -2, 0, 0, 0, 0, 0, 41, 33, 28,
|
0, -2, 0, 0, 0, 0, 0, 41, 33, 28,
|
||||||
23, 24, 0, 1, 0, 0, 0, 0, 9, 14,
|
23, 24, 0, 1, 0, 0, 0, 0, 9, 14,
|
||||||
0, 0, 0, 12, 0, 25, 0, 0, 0, 0,
|
0, 0, 0, 12, 0, 25, 0, 0, 0, 0,
|
||||||
@ -178,8 +180,8 @@ var yyDef = [...]int{
|
|||||||
2, 7, 10, 15, 0, -2, -2, 13, 0, 21,
|
2, 7, 10, 15, 0, -2, -2, 13, 0, 21,
|
||||||
0, 0, 32, 22, 0, 18, 19, 16,
|
0, 0, 32, 22, 0, 18, 19, 16,
|
||||||
}
|
}
|
||||||
var yyTok1 = [...]int{
|
|
||||||
|
|
||||||
|
var yyTok1 = [...]int{
|
||||||
1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
@ -194,11 +196,12 @@ var yyTok1 = [...]int{
|
|||||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||||
3, 3, 3, 3, 22,
|
3, 3, 3, 3, 22,
|
||||||
}
|
}
|
||||||
var yyTok2 = [...]int{
|
|
||||||
|
|
||||||
|
var yyTok2 = [...]int{
|
||||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||||
12, 13, 14, 15, 16, 17, 18, 19, 20,
|
12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
var yyTok3 = [...]int{
|
var yyTok3 = [...]int{
|
||||||
0,
|
0,
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,7 @@ func BenchmarkTemplate_Render(b *testing.B) {
|
|||||||
}
|
}
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
tpl.Render(bindings)
|
_, err := tpl.Render(bindings)
|
||||||
|
require.NoError(b, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ func BenchmarkDrop_Resolve_3(b *testing.B) {
|
|||||||
values <- d.Int()
|
values <- d.Int()
|
||||||
}
|
}
|
||||||
for i := cap(values); i > 0; i-- {
|
for i := cap(values); i > 0; i-- {
|
||||||
|
//lint:ignore S1005 TODO look up how else to read the values
|
||||||
_ = <-values
|
_ = <-values
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user