@@ -3,7 +3,6 @@ package todos
33import (
44 "bufio"
55 "context"
6- "regexp"
76 "strings"
87
98 "github.com/augmentable-dev/tickgit/pkg/blame"
@@ -16,6 +15,7 @@ import (
1615type ToDo struct {
1716 comments.Comment
1817 String string
18+ Phrase string
1919 Blame * blame.Blame
2020}
2121
@@ -32,16 +32,28 @@ func (t *ToDo) TimeAgo() string {
3232
3333// NewToDo produces a pointer to a ToDo from a comment
3434func NewToDo (comment comments.Comment ) * ToDo {
35- s := comment .String ()
36- if ! strings .Contains (s , "TODO" ) {
37- return nil
35+ // FIXME this should be configurable and probably NOT hardcoded here
36+ // in fact, this list might be too expansive for a sensible default
37+ startingMatchPhrases := []string {"TODO" , "FIXME" , "OPTIMIZE" , "HACK" , "XXX" , "WTF" , "LEGACY" }
38+ var matchPhrases []string
39+ for _ , phrase := range startingMatchPhrases {
40+ // populates matchPhrases with the contents of startingMatchPhrases plus the @+lowerCase version of each phrase
41+ matchPhrases = append (matchPhrases , phrase , "@" + strings .ToLower (phrase ))
3842 }
39- re := regexp .MustCompile (`TODO(:|,)?` )
40- s = re .ReplaceAllLiteralString (comment .String (), "" )
41- s = strings .Trim (s , " " )
4243
43- todo := ToDo {Comment : comment , String : s }
44- return & todo
44+ for _ , phrase := range matchPhrases {
45+ s := comment .String ()
46+ if strings .Contains (s , phrase ) {
47+ todo := ToDo {
48+ Comment : comment ,
49+ String : strings .Trim (s , " " ),
50+ Phrase : phrase ,
51+ }
52+ return & todo
53+ }
54+ }
55+
56+ return nil
4557}
4658
4759// NewToDos produces a list of ToDos from a list of comments
0 commit comments