lib/todoist/plugin.rb in danger-todoist-1.1.0 vs lib/todoist/plugin.rb in danger-todoist-1.2.0

- old
+ new

@@ -27,20 +27,28 @@ # @see hanneskaeufler/danger-todoist # @tags todos, fixme # class DangerTodoist < Plugin DEFAULT_MESSAGE = "There remain todo items in the modified code.".freeze + DEFAULT_KEYWORDS = %w(TODO FIXME).freeze # # Message to be shown # # @attr_writer [String] message Custom message shown when todos were found # @return [void] # attr_writer :message # + # Keywords to recognize as todos + # + # @attr_writer [Array] keywords Custom array of strings to identify todos + # @return [void] + attr_writer :keywords + + # # Adds a warning if there are todos found in the modified code # # @return [void] # def warn_for_todos @@ -98,13 +106,19 @@ def find_todos @todos = [] return if files_of_interest.empty? - @todos = DiffTodoFinder.new.find_diffs_containing_todos(diffs_of_interest) + @todos = DiffTodoFinder.new(keywords) + .find_diffs_containing_todos(diffs_of_interest) end + def keywords + return @keywords unless @keywords.nil? + DEFAULT_KEYWORDS + end + def message return @message unless @message.nil? DEFAULT_MESSAGE end @@ -112,9 +126,10 @@ git.modified_files + git.added_files end def diffs_of_interest files_of_interest + .compact .map { |file| git.diff_for_file(file) } end end end