Skip to content

Commit 393cb34

Browse files
committed
Add linting, fix linting issues
1 parent 15c8782 commit 393cb34

File tree

6 files changed

+17
-29
lines changed

6 files changed

+17
-29
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
language: go
22

3-
install: go get golang.org/x/tools/imports/...
3+
install:
4+
- go get golang.org/x/tools/imports/...
5+
- wget -qO- https://github.com/golangci/golangci-lint/releases/download/v1.3.7/golangci-lint-1.3.7-linux-amd64.tar.gz | tar xvz --strip 1 golangci-lint-1.3.7-linux-amd64/golangci-lint
46

5-
script: go test -v ./...
7+
script:
8+
- GOVERSION=$(go version | awk '{ print $3 }')
9+
- test $GOVERSION = "devel" || ./golangci-lint run -v ./...
10+
- go test -v ./...
611

712
go:
813
- 1.7.x

ast/ast.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,18 +501,18 @@ outer:
501501
consumeN := 0
502502
switch rn {
503503
case '\\':
504-
rn, _, _ := r.ReadRune()
504+
rn, _, _ := r.ReadRune() // nolint: gas
505505
switch rn {
506506
case ']':
507507
chars = append(chars, rn)
508508
continue
509509

510510
case 'p':
511-
rn, _, _ := r.ReadRune()
511+
rn, _, _ := r.ReadRune() // nolint: gas
512512
if rn == '{' {
513513
buf.Reset()
514514
for {
515-
rn, _, _ := r.ReadRune()
515+
rn, _, _ := r.ReadRune() // nolint: gas
516516
if rn == '}' {
517517
break
518518
}
@@ -537,7 +537,7 @@ outer:
537537
buf.Reset()
538538
buf.WriteRune(rn)
539539
for i := 0; i < consumeN; i++ {
540-
rn, _, _ := r.ReadRune()
540+
rn, _, _ := r.ReadRune() // nolint: gas
541541
buf.WriteRune(rn)
542542
}
543543
rn, _, _, _ = strconv.UnquoteChar("\\"+buf.String(), 0)

ast/ast_optimize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func set(m map[string]map[string]struct{}, src, dst string) {
6868
// optimize is a Visitor, which is used with the Walk function
6969
// The purpose of this function is to perform the actual optimizations.
7070
// See Optimize for a detailed list of the performed optimizations.
71-
func (r *grammarOptimizer) optimize(expr0 Expression) Visitor {
71+
func (r *grammarOptimizer) optimize(expr0 Expression) Visitor { // nolint: gocyclo
7272
switch expr := expr0.(type) {
7373
case *ActionExpr:
7474
expr.Expr = r.optimizeRule(expr.Expr)

bootstrap/cmd/pegscan/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func main() {
1515
if len(os.Args) > 2 {
16-
fmt.Fprintln(os.Stderr, "USAGE: pegscan FILE")
16+
fmt.Fprintln(os.Stderr, "USAGE: pegscan FILE") // nolint: gas
1717
os.Exit(1)
1818
}
1919

builder/static_code.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,11 @@ type expr struct {
317317
expr interface{}
318318
}
319319

320-
type andExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
321-
type notExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
322-
type zeroOrOneExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
320+
type andExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
321+
type notExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
322+
type zeroOrOneExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
323323
type zeroOrMoreExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
324-
type oneOrMoreExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
324+
type oneOrMoreExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
325325

326326
//{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }}
327327
type ruleRefExpr struct {
@@ -475,7 +475,6 @@ func (p *parser) setOptions(opts []Option) {
475475
}
476476
}
477477

478-
479478
//{{ if .Nolint }} nolint: structcheck,deadcode {{else}} ==template== {{ end }}
480479
type resultTuple struct {
481480
v interface{}

misc/cmd/unicode-classes/main.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,3 @@ func main() {
3636
}
3737
fmt.Println("}")
3838
}
39-
40-
// lenSorter was used to generate Unicode classes directly in the PEG
41-
// grammar (where longer classes had to come first).
42-
type lenSorter []string
43-
44-
func (l lenSorter) Len() int { return len(l) }
45-
func (l lenSorter) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
46-
func (l lenSorter) Less(i, j int) bool {
47-
li, lj := len(l[i]), len(l[j])
48-
if lj < li {
49-
return true
50-
} else if li < lj {
51-
return false
52-
}
53-
return l[j] < l[i]
54-
}

0 commit comments

Comments
 (0)