Skip to content

Commit

Permalink
Add linting, fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
breml committed Jun 4, 2018
1 parent 15c8782 commit 393cb34
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 29 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ast/ast_optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/cmd/pegscan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 4 additions & 5 deletions builder/static_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -475,7 +475,6 @@ func (p *parser) setOptions(opts []Option) {
}
}


//{{ if .Nolint }} nolint: structcheck,deadcode {{else}} ==template== {{ end }}
type resultTuple struct {
v interface{}
Expand Down
16 changes: 0 additions & 16 deletions misc/cmd/unicode-classes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

0 comments on commit 393cb34

Please sign in to comment.