Skip to content

Commit

Permalink
Use ast/token/parser instead of string handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bombsimon committed Mar 21, 2019
1 parent c105ebf commit 65080d2
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 129 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func main() {
files = append(files, m.FullName())
}

r := ProcessFiles(files)
r := ProcessFiles([]string{flag.Args()[0]})

for _, x := range r {
fmt.Printf("%s:%d: %s\n", x.FileName, x.LineNo, x.Reason)
fmt.Printf("%s:%d: %s\n", x.FileName, x.LineNumber, x.Reason)
}

if len(r) > 0 {
Expand Down
30 changes: 16 additions & 14 deletions testfiles/01.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"flag"
"fmt"
"log"
)

Expand All @@ -24,6 +25,8 @@ func main() {
t, data, done := job.BuildTree(schan)
<-done

fmt.Println(data)

// finish stream
t.Update(&syntax.Node{Type: -1})

Expand All @@ -35,30 +38,29 @@ func main() {

somevar := 1
somevar2 := 2
if foo {
panic("this")
if somevar {
panic(somevar2)
}

_, err := thisFunc()
if err != nil {
ShouldBeOK()
ShouldBeOK()
}

if true {
if false {
if true {
fmt.Println("We have to go deeper!")

if true {
if false {
if true {
fmt.Println("We have to go deeper!")

}
}
}
}
}
}
}

func thisFunc() bool, error {
return false, nil
func thisFunc() (bool, error) {
return false, nil
}

func ShouldBeOK() {
fmt.Println("Don't be sad")
fmt.Println("Don't be sad")
}
1 change: 1 addition & 0 deletions testfiles/01_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package one
func main() {

// This violates EVERYTHING
return

}

0 comments on commit 65080d2

Please sign in to comment.