Sha256: 5faae4420dd59e5d0c00f01ef787d0dc7ee7292047be5f5edb526e0e73cdb8b2

Contents?: true

Size: 476 Bytes

Versions: 1

Compression:

Stored size: 476 Bytes

Contents

module Danger
  # Identify todos in a set of diffs
  class DiffTodoFinder
    TODO_REGEXP = /\+.*(TODO|FIXME)[\s:]/i

    def find_diffs_containing_todos(diffs)
      diffs
        .select { |diff| contains_new_todo(diff) }
        .map { |diff| Todo.new(diff.path) }
    end

    private

    def contains_new_todo(diff)
      # TODO: This will match removed todos as well
      !(diff.patch =~ TODO_REGEXP).nil?
    end

    class Todo < Struct.new(:file)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-todoist-0.0.3 lib/todoist/diff_todo_finder.rb