mirror of
https://github.com/danog/liquid.git
synced 2024-11-30 07:48:58 +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("")
|
_ = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
101
expressions/y.go
101
expressions/y.go
@ -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,
|
||||||
}
|
}
|
||||||
@ -542,87 +545,87 @@ yydefault:
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line expressions.y:46
|
//line expressions.y:46
|
||||||
{
|
{
|
||||||
yylex.(*lexer).val = yyDollar[1].f
|
yylex.(*lexer).val = yyDollar[1].f
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
yyDollar = yyS[yypt-5 : yypt+1]
|
yyDollar = yyS[yypt-5 : yypt+1]
|
||||||
//line expressions.y:47
|
//line expressions.y:47
|
||||||
{
|
{
|
||||||
yylex.(*lexer).Assignment = Assignment{yyDollar[2].name, &expression{yyDollar[4].f}}
|
yylex.(*lexer).Assignment = Assignment{yyDollar[2].name, &expression{yyDollar[4].f}}
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:50
|
//line expressions.y:50
|
||||||
{
|
{
|
||||||
yylex.(*lexer).Cycle = yyDollar[2].cycle
|
yylex.(*lexer).Cycle = yyDollar[2].cycle
|
||||||
}
|
}
|
||||||
case 4:
|
case 4:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:51
|
//line expressions.y:51
|
||||||
{
|
{
|
||||||
yylex.(*lexer).Loop = yyDollar[2].loop
|
yylex.(*lexer).Loop = yyDollar[2].loop
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:52
|
//line expressions.y:52
|
||||||
{
|
{
|
||||||
yylex.(*lexer).When = When{yyDollar[2].exprs}
|
yylex.(*lexer).When = When{yyDollar[2].exprs}
|
||||||
}
|
}
|
||||||
case 6:
|
case 6:
|
||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line expressions.y:55
|
//line expressions.y:55
|
||||||
{
|
{
|
||||||
yyVAL.cycle = yyDollar[2].cyclefn(yyDollar[1].s)
|
yyVAL.cycle = yyDollar[2].cyclefn(yyDollar[1].s)
|
||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:58
|
//line expressions.y:58
|
||||||
{
|
{
|
||||||
h, t := yyDollar[2].s, yyDollar[3].ss
|
h, t := yyDollar[2].s, yyDollar[3].ss
|
||||||
yyVAL.cyclefn = func(g string) Cycle { return Cycle{g, append([]string{h}, t...)} }
|
yyVAL.cyclefn = func(g string) Cycle { return Cycle{g, append([]string{h}, t...)} }
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line expressions.y:62
|
//line expressions.y:62
|
||||||
{
|
{
|
||||||
vals := yyDollar[1].ss
|
vals := yyDollar[1].ss
|
||||||
yyVAL.cyclefn = func(h string) Cycle { return Cycle{Values: append([]string{h}, vals...)} }
|
yyVAL.cyclefn = func(h string) Cycle { return Cycle{Values: append([]string{h}, vals...)} }
|
||||||
}
|
}
|
||||||
case 9:
|
case 9:
|
||||||
yyDollar = yyS[yypt-0 : yypt+1]
|
yyDollar = yyS[yypt-0 : yypt+1]
|
||||||
//line expressions.y:69
|
//line expressions.y:69
|
||||||
{
|
{
|
||||||
yyVAL.ss = []string{}
|
yyVAL.ss = []string{}
|
||||||
}
|
}
|
||||||
case 10:
|
case 10:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:70
|
//line expressions.y:70
|
||||||
{
|
{
|
||||||
yyVAL.ss = append([]string{yyDollar[2].s}, yyDollar[3].ss...)
|
yyVAL.ss = append([]string{yyDollar[2].s}, yyDollar[3].ss...)
|
||||||
}
|
}
|
||||||
case 11:
|
case 11:
|
||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line expressions.y:73
|
//line expressions.y:73
|
||||||
{
|
{
|
||||||
yyVAL.exprs = append([]Expression{&expression{yyDollar[1].f}}, yyDollar[2].exprs...)
|
yyVAL.exprs = append([]Expression{&expression{yyDollar[1].f}}, yyDollar[2].exprs...)
|
||||||
}
|
}
|
||||||
case 12:
|
case 12:
|
||||||
yyDollar = yyS[yypt-0 : yypt+1]
|
yyDollar = yyS[yypt-0 : yypt+1]
|
||||||
//line expressions.y:75
|
//line expressions.y:75
|
||||||
{
|
{
|
||||||
yyVAL.exprs = []Expression{}
|
yyVAL.exprs = []Expression{}
|
||||||
}
|
}
|
||||||
case 13:
|
case 13:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:76
|
//line expressions.y:76
|
||||||
{
|
{
|
||||||
yyVAL.exprs = append([]Expression{&expression{yyDollar[2].f}}, yyDollar[3].exprs...)
|
yyVAL.exprs = append([]Expression{&expression{yyDollar[2].f}}, yyDollar[3].exprs...)
|
||||||
}
|
}
|
||||||
case 14:
|
case 14:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line expressions.y:79
|
//line expressions.y:79
|
||||||
{
|
{
|
||||||
s, ok := yyDollar[1].val.(string)
|
s, ok := yyDollar[1].val.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -632,40 +635,40 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 15:
|
case 15:
|
||||||
yyDollar = yyS[yypt-4 : yypt+1]
|
yyDollar = yyS[yypt-4 : yypt+1]
|
||||||
//line expressions.y:87
|
//line expressions.y:87
|
||||||
{
|
{
|
||||||
name, expr, mods := yyDollar[1].name, yyDollar[3].f, yyDollar[4].loopmods
|
name, expr, mods := yyDollar[1].name, yyDollar[3].f, yyDollar[4].loopmods
|
||||||
yyVAL.loop = Loop{name, &expression{expr}, mods}
|
yyVAL.loop = Loop{name, &expression{expr}, mods}
|
||||||
}
|
}
|
||||||
case 16:
|
case 16:
|
||||||
yyDollar = yyS[yypt-5 : yypt+1]
|
yyDollar = yyS[yypt-5 : yypt+1]
|
||||||
//line expressions.y:93
|
//line expressions.y:93
|
||||||
{
|
{
|
||||||
yyVAL.f = makeRangeExpr(yyDollar[2].f, yyDollar[4].f)
|
yyVAL.f = makeRangeExpr(yyDollar[2].f, yyDollar[4].f)
|
||||||
}
|
}
|
||||||
case 18:
|
case 18:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line expressions.y:101
|
//line expressions.y:101
|
||||||
{
|
{
|
||||||
val := yyDollar[1].val
|
val := yyDollar[1].val
|
||||||
yyVAL.f = func(Context) values.Value { return values.ValueOf(val) }
|
yyVAL.f = func(Context) values.Value { return values.ValueOf(val) }
|
||||||
}
|
}
|
||||||
case 19:
|
case 19:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line expressions.y:102
|
//line expressions.y:102
|
||||||
{
|
{
|
||||||
name := yyDollar[1].name
|
name := yyDollar[1].name
|
||||||
yyVAL.f = func(ctx Context) values.Value { return values.ValueOf(ctx.Get(name)) }
|
yyVAL.f = func(ctx Context) values.Value { return values.ValueOf(ctx.Get(name)) }
|
||||||
}
|
}
|
||||||
case 20:
|
case 20:
|
||||||
yyDollar = yyS[yypt-0 : yypt+1]
|
yyDollar = yyS[yypt-0 : yypt+1]
|
||||||
//line expressions.y:105
|
//line expressions.y:105
|
||||||
{
|
{
|
||||||
yyVAL.loopmods = loopModifiers{Cols: math.MaxUint32}
|
yyVAL.loopmods = loopModifiers{Cols: math.MaxUint32}
|
||||||
}
|
}
|
||||||
case 21:
|
case 21:
|
||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line expressions.y:106
|
//line expressions.y:106
|
||||||
{
|
{
|
||||||
switch yyDollar[2].name {
|
switch yyDollar[2].name {
|
||||||
case "reversed":
|
case "reversed":
|
||||||
@ -677,7 +680,7 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 22:
|
case 22:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:115
|
//line expressions.y:115
|
||||||
{ // TODO can this be a variable?
|
{ // TODO can this be a variable?
|
||||||
switch yyDollar[2].name {
|
switch yyDollar[2].name {
|
||||||
case "cols":
|
case "cols":
|
||||||
@ -705,63 +708,63 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 23:
|
case 23:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line expressions.y:143
|
//line expressions.y:143
|
||||||
{
|
{
|
||||||
val := yyDollar[1].val
|
val := yyDollar[1].val
|
||||||
yyVAL.f = func(Context) values.Value { return values.ValueOf(val) }
|
yyVAL.f = func(Context) values.Value { return values.ValueOf(val) }
|
||||||
}
|
}
|
||||||
case 24:
|
case 24:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line expressions.y:144
|
//line expressions.y:144
|
||||||
{
|
{
|
||||||
name := yyDollar[1].name
|
name := yyDollar[1].name
|
||||||
yyVAL.f = func(ctx Context) values.Value { return values.ValueOf(ctx.Get(name)) }
|
yyVAL.f = func(ctx Context) values.Value { return values.ValueOf(ctx.Get(name)) }
|
||||||
}
|
}
|
||||||
case 25:
|
case 25:
|
||||||
yyDollar = yyS[yypt-2 : yypt+1]
|
yyDollar = yyS[yypt-2 : yypt+1]
|
||||||
//line expressions.y:145
|
//line expressions.y:145
|
||||||
{
|
{
|
||||||
yyVAL.f = makeObjectPropertyExpr(yyDollar[1].f, yyDollar[2].name)
|
yyVAL.f = makeObjectPropertyExpr(yyDollar[1].f, yyDollar[2].name)
|
||||||
}
|
}
|
||||||
case 26:
|
case 26:
|
||||||
yyDollar = yyS[yypt-4 : yypt+1]
|
yyDollar = yyS[yypt-4 : yypt+1]
|
||||||
//line expressions.y:146
|
//line expressions.y:146
|
||||||
{
|
{
|
||||||
yyVAL.f = makeIndexExpr(yyDollar[1].f, yyDollar[3].f)
|
yyVAL.f = makeIndexExpr(yyDollar[1].f, yyDollar[3].f)
|
||||||
}
|
}
|
||||||
case 27:
|
case 27:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:147
|
//line expressions.y:147
|
||||||
{
|
{
|
||||||
yyVAL.f = yyDollar[2].f
|
yyVAL.f = yyDollar[2].f
|
||||||
}
|
}
|
||||||
case 29:
|
case 29:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:152
|
//line expressions.y:152
|
||||||
{
|
{
|
||||||
yyVAL.f = makeFilter(yyDollar[1].f, yyDollar[3].name, nil)
|
yyVAL.f = makeFilter(yyDollar[1].f, yyDollar[3].name, nil)
|
||||||
}
|
}
|
||||||
case 30:
|
case 30:
|
||||||
yyDollar = yyS[yypt-4 : yypt+1]
|
yyDollar = yyS[yypt-4 : yypt+1]
|
||||||
//line expressions.y:153
|
//line expressions.y:153
|
||||||
{
|
{
|
||||||
yyVAL.f = makeFilter(yyDollar[1].f, yyDollar[3].name, yyDollar[4].filter_params)
|
yyVAL.f = makeFilter(yyDollar[1].f, yyDollar[3].name, yyDollar[4].filter_params)
|
||||||
}
|
}
|
||||||
case 31:
|
case 31:
|
||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line expressions.y:157
|
//line expressions.y:157
|
||||||
{
|
{
|
||||||
yyVAL.filter_params = []valueFn{yyDollar[1].f}
|
yyVAL.filter_params = []valueFn{yyDollar[1].f}
|
||||||
}
|
}
|
||||||
case 32:
|
case 32:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:159
|
//line expressions.y:159
|
||||||
{
|
{
|
||||||
yyVAL.filter_params = append(yyDollar[1].filter_params, yyDollar[3].f)
|
yyVAL.filter_params = append(yyDollar[1].filter_params, yyDollar[3].f)
|
||||||
}
|
}
|
||||||
case 34:
|
case 34:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:163
|
//line expressions.y:163
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
@ -771,7 +774,7 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 35:
|
case 35:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:170
|
//line expressions.y:170
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
@ -781,7 +784,7 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 36:
|
case 36:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:177
|
//line expressions.y:177
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
@ -791,7 +794,7 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 37:
|
case 37:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:184
|
//line expressions.y:184
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
@ -801,7 +804,7 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 38:
|
case 38:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:191
|
//line expressions.y:191
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
@ -811,7 +814,7 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 39:
|
case 39:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:198
|
//line expressions.y:198
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
@ -821,13 +824,13 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 40:
|
case 40:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:205
|
//line expressions.y:205
|
||||||
{
|
{
|
||||||
yyVAL.f = makeContainsExpr(yyDollar[1].f, yyDollar[3].f)
|
yyVAL.f = makeContainsExpr(yyDollar[1].f, yyDollar[3].f)
|
||||||
}
|
}
|
||||||
case 42:
|
case 42:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:210
|
//line expressions.y:210
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
@ -836,7 +839,7 @@ yydefault:
|
|||||||
}
|
}
|
||||||
case 43:
|
case 43:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
//line expressions.y:216
|
//line expressions.y:216
|
||||||
{
|
{
|
||||||
fa, fb := yyDollar[1].f, yyDollar[3].f
|
fa, fb := yyDollar[1].f, yyDollar[3].f
|
||||||
yyVAL.f = func(ctx Context) values.Value {
|
yyVAL.f = func(ctx Context) values.Value {
|
||||||
|
@ -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