NewToDo produces a pointer to a ToDo from a comment
(comment comments.Comment)
| 30 | |
| 31 | // NewToDo produces a pointer to a ToDo from a comment |
| 32 | func 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 |
| 58 | func NewToDos(comments comments.Comments) ToDos { |