MCPcopy Create free account
hub / github.com/augmentable-dev/tickgit / NewToDo

Function NewToDo

pkg/todos/todos.go:32–55  ·  view source on GitHub ↗

NewToDo produces a pointer to a ToDo from a comment

(comment comments.Comment)

Source from the content-addressed store, hash-verified

30
31// NewToDo produces a pointer to a ToDo from a comment
32func NewToDo(comment comments.Comment) *ToDo {
33 // FIXME this should be configurable and probably NOT hardcoded here
34 // in fact, this list might be too expansive for a sensible default
35 startingMatchPhrases := []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"}
36 var matchPhrases []string
37 for _, phrase := range startingMatchPhrases {
38 // populates matchPhrases with the contents of startingMatchPhrases plus the @+lowerCase version of each phrase
39 matchPhrases = append(matchPhrases, phrase, "@"+strings.ToLower(phrase))
40 }
41
42 for _, phrase := range matchPhrases {
43 s := comment.String()
44 if strings.Contains(s, phrase) {
45 todo := ToDo{
46 Comment: comment,
47 String: strings.Trim(s, " "),
48 Phrase: phrase,
49 }
50 return &todo
51 }
52 }
53
54 return nil
55}
56
57// NewToDos produces a list of ToDos from a list of comments
58func NewToDos(comments comments.Comments) ToDos {

Callers 4

todos.goFile · 0.92
NewToDosFunction · 0.85
TestNewToDoNilFunction · 0.85
TestNewToDoFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by 2

TestNewToDoNilFunction · 0.68
TestNewToDoFunction · 0.68