Updated project todos and go fmt

This commit is contained in:
Samuel Hawksby-Robinson 2021-01-07 12:57:18 +00:00
parent d0d6297b7d
commit 715a868281
No known key found for this signature in database
GPG Key ID: 64CF99D4A64A1205
5 changed files with 15 additions and 11 deletions

View File

@ -6,6 +6,10 @@ import "fmt"
// TODO check if to-do is just above a function or struct, if so assume the to-do is about the function
// TODO output to a file
// TODO add execution params to the running of the application, allowing to set the path, keywords, ignore list, language, etc
const (
statusDir = "../status-go"
ignore = statusDir + "/vendor"

View File

@ -71,11 +71,11 @@ func (n node) toString(indent int) string {
switch c.Type {
case DIR:
out += idnt + "- 📁 " + c.Name + "\n"
out += c.toString(indent+1)
out += c.toString(indent + 1)
case FILE:
out += idnt + "- 📃 " + c.Name + "\n"
for _, t := range c.Todos {
todoIdnt := idnt+baseIdnt+baseIdnt
todoIdnt := idnt + baseIdnt + baseIdnt
ts := strings.ReplaceAll(t.String(), "\n", "\n"+todoIdnt)
out += idnt + baseIdnt + "- ⬜ Todo:\n" + todoIdnt + ts + "\n"
}
@ -83,4 +83,4 @@ func (n node) toString(indent int) string {
}
return out
}
}

View File

@ -10,7 +10,7 @@ type todo struct {
Description string
LineNumber int
RelatedFuncOrType string
filePathSlice []string
filePathSlice []string
}
func (t *todo) Path() []string {
@ -42,10 +42,10 @@ func (t *todo) String() string {
l3 := "*Description* : "
if t.RelatedFuncOrType != "" {
out += l1+ " `" + t.RelatedFuncOrType + "`" + "\n"
out += l1 + " `" + t.RelatedFuncOrType + "`" + "\n"
}
return out +
fmt.Sprintf("%s %d \n", l2, t.LineNumber) +
l3 + t.Description
}
}

View File

@ -11,8 +11,8 @@ import (
type TodoFinder struct {
// regex related fields
entityTracker *entityTracker
todoRegex *regexp.Regexp
lineRegex *regexp.Regexp
todoRegex *regexp.Regexp
lineRegex *regexp.Regexp
// results store
FoundTable []*todo
@ -28,7 +28,7 @@ func NewTodoFinder() (TodoFinder, error) {
tf := TodoFinder{
FoundTable: []*todo{},
foundTree: &node{Name: "root", Type: DIR},
keywords: []string{"todo", "fixme"},
keywords: []string{"todo", "fixme"},
}
return tf, tf.init()
@ -122,7 +122,7 @@ func (tf *TodoFinder) FindInDir(dir string) error {
return nil
}
func (tf TodoFinder) isGoFile(name string) bool {
func (tf TodoFinder) isGoFile(name string) bool {
if len(name) < 3 {
return false
}

View File

@ -6,7 +6,7 @@ import (
)
func TestNode_AddToTree(t *testing.T) {
n := &node{Name: "root", Type: "dir"}
n := &node{Name: "root", Type: DIR}
td := &todo{
Filepath: "../status-go/admin/sales/donkeys/pokemon/gif.go",
Description: "this looks borken",