2021-01-04 23:53:22 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-01-05 11:16:34 +00:00
|
|
|
"fmt"
|
2021-01-06 16:38:12 +00:00
|
|
|
"github.com/davecgh/go-spew/spew"
|
2021-01-05 11:16:34 +00:00
|
|
|
"unicode"
|
2021-01-04 23:53:22 +00:00
|
|
|
)
|
|
|
|
|
2021-01-05 14:43:12 +00:00
|
|
|
// TODO implement dynamic comment token selection, could maybe work similar to entityTracker{}
|
2021-01-05 11:16:34 +00:00
|
|
|
|
2021-01-05 14:43:12 +00:00
|
|
|
// TODO check if to-do is just above a function or struct, if so assume the to-do is about the function
|
2021-01-05 11:16:34 +00:00
|
|
|
|
2021-01-04 23:53:22 +00:00
|
|
|
const (
|
|
|
|
statusDir = "../status-go"
|
2021-01-05 14:44:31 +00:00
|
|
|
ignore = statusDir + "/vendor"
|
2021-01-04 23:53:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2021-01-06 14:41:25 +00:00
|
|
|
keywords = []string{"todo", "fixme"}
|
2021-01-04 23:53:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-01-06 16:29:03 +00:00
|
|
|
tf := NewTodoFinder()
|
|
|
|
|
2021-01-06 16:38:12 +00:00
|
|
|
err := tf.FindInDir(statusDir)
|
2021-01-04 23:53:22 +00:00
|
|
|
if err != nil {
|
2021-01-06 16:38:12 +00:00
|
|
|
panic(err)
|
2021-01-04 23:53:22 +00:00
|
|
|
}
|
|
|
|
|
2021-01-06 16:38:12 +00:00
|
|
|
spew.Dump(tf.foundTree)
|
2021-01-04 23:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func isGoFile(name string) bool {
|
|
|
|
if len(name) < 3 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
last := name[len(name)-3:]
|
|
|
|
return last == ".go"
|
|
|
|
}
|
2021-01-05 11:16:34 +00:00
|
|
|
|
|
|
|
func buildRegexPattern(keywords []string) string {
|
|
|
|
kwp := makeRegexKeywords(keywords)
|
2021-01-05 11:44:48 +00:00
|
|
|
return fmt.Sprintf("//.*((%s)(.*))", kwp)
|
2021-01-05 11:16:34 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 12:06:41 +00:00
|
|
|
func makeRegexKeywords(keywords []string) (out string) {
|
2021-01-05 11:16:34 +00:00
|
|
|
for i, kw := range keywords {
|
|
|
|
for _, r := range kw {
|
|
|
|
lower := unicode.ToLower(r)
|
|
|
|
upper := unicode.ToUpper(r)
|
|
|
|
|
|
|
|
out += fmt.Sprintf("[%s,%s]", string(lower), string(upper))
|
|
|
|
}
|
|
|
|
|
|
|
|
if i+1 < len(keywords) {
|
|
|
|
out += "|"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 12:06:41 +00:00
|
|
|
return
|
2021-01-05 11:16:34 +00:00
|
|
|
}
|