diff --git a/cmd/tickgit/commands/todos.go b/cmd/tickgit/commands/todos.go index d9d749e..b9ae311 100644 --- a/cmd/tickgit/commands/todos.go +++ b/cmd/tickgit/commands/todos.go @@ -17,6 +17,7 @@ import ( ) var csvOutput bool +var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} func init() { todosCmd.Flags().BoolVar(&csvOutput, "csv-output", false, "specify whether or not output should be in CSV format") @@ -47,7 +48,7 @@ var todosCmd = &cobra.Command{ foundToDos := make(todos.ToDos, 0) err = comments.SearchDir(dir, func(comment *comments.Comment) { - todo := todos.NewToDo(*comment) + todo := todos.NewToDo(*comment, startingMatchPhrases) if todo != nil { foundToDos = append(foundToDos, todo) s.Suffix = fmt.Sprintf(" %d TODOs found", len(foundToDos)) diff --git a/pkg/todos/todos.go b/pkg/todos/todos.go index 6921be9..1a66ba6 100644 --- a/pkg/todos/todos.go +++ b/pkg/todos/todos.go @@ -29,12 +29,10 @@ func (t *ToDo) TimeAgo() string { } // NewToDo produces a pointer to a ToDo from a comment -func NewToDo(comment comments.Comment) *ToDo { +func NewToDo(comment comments.Comment, matchPhrases []string) *ToDo { // FIXME this should be configurable and probably NOT hardcoded here - // in fact, this list might be too expansive for a sensible default - startingMatchPhrases := []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} - var matchPhrases []string - for _, phrase := range startingMatchPhrases { + // in fact, this list might be too expansive for a sensible defaul + for _, phrase := range matchPhrases { // populates matchPhrases with the contents of startingMatchPhrases plus the @+lowerCase version of each phrase matchPhrases = append(matchPhrases, phrase, "@"+strings.ToLower(phrase)) } @@ -55,10 +53,10 @@ func NewToDo(comment comments.Comment) *ToDo { } // NewToDos produces a list of ToDos from a list of comments -func NewToDos(comments comments.Comments) ToDos { +func NewToDos(comments comments.Comments, matchPhrases []string) ToDos { todos := make(ToDos, 0) for _, comment := range comments { - todo := NewToDo(*comment) + todo := NewToDo(*comment, matchPhrases) if todo != nil { todos = append(todos, todo) } diff --git a/pkg/todos/todos_test.go b/pkg/todos/todos_test.go index 8b71967..e2777d6 100644 --- a/pkg/todos/todos_test.go +++ b/pkg/todos/todos_test.go @@ -7,12 +7,14 @@ import ( "github.com/augmentable-dev/tickgit/pkg/comments" ) +var startingMatchPhrases []string = []string{"TODO", "FIXME", "OPTIMIZE", "HACK", "XXX", "WTF", "LEGACY"} + func TestNewToDoNil(t *testing.T) { collection := lege.NewCollection(lege.Location{}, lege.Location{}, lege.Boundary{}, "Hello World") comment := comments.Comment{ Collection: *collection, } - todo := NewToDo(comment) + todo := NewToDo(comment, startingMatchPhrases) if todo != nil { t.Fatalf("did not expect a TODO, got: %v", todo) @@ -24,7 +26,7 @@ func TestNewToDo(t *testing.T) { comment := comments.Comment{ Collection: *collection, } - todo := NewToDo(comment) + todo := NewToDo(comment, startingMatchPhrases) if todo == nil { t.Fatalf("expected a TODO, got: %v", todo)