diff --git a/.travis.yml b/.travis.yml index 22a5cb5d..c3ed10de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,13 @@ language: go -install: go get golang.org/x/tools/imports/... +install: + - go get golang.org/x/tools/imports/... + - 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 -script: go test -v ./... +script: + - GOVERSION=$(go version | awk '{ print $3 }') + - test $GOVERSION = "devel" || ./golangci-lint run -v ./... + - go test -v ./... go: - 1.7.x diff --git a/ast/ast.go b/ast/ast.go index c34b7d17..ea500386 100644 --- a/ast/ast.go +++ b/ast/ast.go @@ -501,18 +501,18 @@ outer: consumeN := 0 switch rn { case '\\': - rn, _, _ := r.ReadRune() + rn, _, _ := r.ReadRune() // nolint: gas switch rn { case ']': chars = append(chars, rn) continue case 'p': - rn, _, _ := r.ReadRune() + rn, _, _ := r.ReadRune() // nolint: gas if rn == '{' { buf.Reset() for { - rn, _, _ := r.ReadRune() + rn, _, _ := r.ReadRune() // nolint: gas if rn == '}' { break } @@ -537,7 +537,7 @@ outer: buf.Reset() buf.WriteRune(rn) for i := 0; i < consumeN; i++ { - rn, _, _ := r.ReadRune() + rn, _, _ := r.ReadRune() // nolint: gas buf.WriteRune(rn) } rn, _, _, _ = strconv.UnquoteChar("\\"+buf.String(), 0) diff --git a/ast/ast_optimize.go b/ast/ast_optimize.go index 13721070..42a764e8 100644 --- a/ast/ast_optimize.go +++ b/ast/ast_optimize.go @@ -68,7 +68,7 @@ func set(m map[string]map[string]struct{}, src, dst string) { // optimize is a Visitor, which is used with the Walk function // The purpose of this function is to perform the actual optimizations. // See Optimize for a detailed list of the performed optimizations. -func (r *grammarOptimizer) optimize(expr0 Expression) Visitor { +func (r *grammarOptimizer) optimize(expr0 Expression) Visitor { // nolint: gocyclo switch expr := expr0.(type) { case *ActionExpr: expr.Expr = r.optimizeRule(expr.Expr) diff --git a/bootstrap/cmd/pegscan/main.go b/bootstrap/cmd/pegscan/main.go index f4bd215e..eaa199d3 100644 --- a/bootstrap/cmd/pegscan/main.go +++ b/bootstrap/cmd/pegscan/main.go @@ -13,7 +13,7 @@ import ( func main() { if len(os.Args) > 2 { - fmt.Fprintln(os.Stderr, "USAGE: pegscan FILE") + fmt.Fprintln(os.Stderr, "USAGE: pegscan FILE") // nolint: gas os.Exit(1) } diff --git a/builder/static_code.go b/builder/static_code.go index ebb9275b..d6834be7 100644 --- a/builder/static_code.go +++ b/builder/static_code.go @@ -317,11 +317,11 @@ type expr struct { expr interface{} } -type andExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} -type notExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} -type zeroOrOneExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} +type andExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} +type notExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} +type zeroOrOneExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} type zeroOrMoreExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} -type oneOrMoreExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} +type oneOrMoreExpr expr //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} //{{ if .Nolint }} nolint: structcheck {{else}} ==template== {{ end }} type ruleRefExpr struct { @@ -475,7 +475,6 @@ func (p *parser) setOptions(opts []Option) { } } - //{{ if .Nolint }} nolint: structcheck,deadcode {{else}} ==template== {{ end }} type resultTuple struct { v interface{} diff --git a/misc/cmd/unicode-classes/main.go b/misc/cmd/unicode-classes/main.go index e3f0aacc..8d8c5599 100644 --- a/misc/cmd/unicode-classes/main.go +++ b/misc/cmd/unicode-classes/main.go @@ -36,19 +36,3 @@ func main() { } fmt.Println("}") } - -// lenSorter was used to generate Unicode classes directly in the PEG -// grammar (where longer classes had to come first). -type lenSorter []string - -func (l lenSorter) Len() int { return len(l) } -func (l lenSorter) Swap(i, j int) { l[i], l[j] = l[j], l[i] } -func (l lenSorter) Less(i, j int) bool { - li, lj := len(l[i]), len(l[j]) - if lj < li { - return true - } else if li < lj { - return false - } - return l[j] < l[i] -}