Class: Danger::DangerTodoist

Inherits:
Plugin
  • Object
show all
Defined in:
lib/todoist/plugin.rb

Overview

This is a danger plugin to detect any TODO/FIXME entries left in the code.

Examples:

Ensure there are no TODOS left in the modified code


todoist.warn_for_todos

Set custom warning message


todois.message = "Please fix all TODOS"
todoist.warn_for_todos

List every todo item


todoist.warn_for_todos
todoist.print_todos_table

See Also:

  • hanneskaeufler/danger-todoist

Constant Summary collapse

DEFAULT_MESSAGE =
"There remain todo items in the modified code.".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#message=(value) ⇒ void

This method returns an undefined value.

Message to be shown



31
32
33
# File 'lib/todoist/plugin.rb', line 31

def message=(value)
  @message = value
end

Instance Method Details

This method returns an undefined value.

Adds a list of offending files to the danger comment



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/todoist/plugin.rb', line 52

def print_todos_table
  return if @todos.nil?
  return if @todos.empty?

  markdown("#### Todos left in files")

  @todos.each do |todo|
    text = ": #{todo.text}" if todo.text
    markdown("- #{todo.file}#{text}")
  end
end

#warn_for_todosvoid

This method returns an undefined value.

Adds a warning if there are todos found in the modified code



38
39
40
41
42
43
44
45
# File 'lib/todoist/plugin.rb', line 38

def warn_for_todos
  @todos = []
  return if files_of_interest.empty?

  @todos = DiffTodoFinder.new.find_diffs_containing_todos(diffs_of_interest)

  warn(message) unless @todos.empty?
end