lib/todoist/plugin.rb in danger-todoist-0.0.2 vs lib/todoist/plugin.rb in danger-todoist-0.0.3
- old
+ new
@@ -19,11 +19,10 @@
# @see hanneskaeufler/danger-todoist
# @tags todos, fixme
#
class DangerTodoist < Plugin
DEFAULT_MESSAGE = "There remain todo items in the modified code.".freeze
- TODO_REGEXP = /TODO|FIXME/i
#
# Message to be shown
#
# @attr_writer [String] message Custom message shown when todos were found
@@ -38,12 +37,11 @@
#
def warn_for_todos
@todos = []
return if files_of_interest.empty?
- diffs_containing_todo_markers
- .each { |diff| @todos << Todo.new(diff.path) }
+ @todos = DiffTodoFinder.new.find_diffs_containing_todos(diffs_of_interest)
warn(message) unless @todos.empty?
end
#
@@ -72,20 +70,8 @@
end
def diffs_of_interest
files_of_interest
.map { |file| git.diff_for_file(file) }
- end
-
- def diffs_containing_todo_markers
- diffs_of_interest
- .select { |diff| contains_new_todo(diff) }
- end
-
- def contains_new_todo(diff)
- !(diff.patch =~ TODO_REGEXP).nil?
- end
-
- class Todo < Struct.new(:file)
end
end
end