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, by warning, there are no TODOS left in the modified code


todoist.warn_for_todos

Ensure, by failing the build, no TODOS left in the modified code


todoist.fail_for_todos

Set custom warning message for warning


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

List every todo item


todoist.warn_for_todos
todoist.print_todos_table

Do anything with the todos. Todos have ‘text` and `file` properties


todoist.todos.each { |todo| puts todo.text }

See Also:

  • hanneskaeufler/danger-todoist

Constant Summary collapse

DEFAULT_MESSAGE =
"There remain todo items in the modified code.".freeze
DEFAULT_KEYWORDS =
%w(TODO FIXME).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keywords=(value) ⇒ void

This method returns an undefined value.

Keywords to recognize as todos



47
48
49
# File 'lib/todoist/plugin.rb', line 47

def keywords=(value)
  @keywords = value
end

#message=(value) ⇒ void

This method returns an undefined value.

Message to be shown



40
41
42
# File 'lib/todoist/plugin.rb', line 40

def message=(value)
  @message = value
end

Instance Method Details

#fail_for_todosvoid

This method returns an undefined value.

Adds an error if there are todos found in the modified code



63
64
65
# File 'lib/todoist/plugin.rb', line 63

def fail_for_todos
  call_method_for_todos(:fail)
end

This method returns an undefined value.

Adds a list of offending files to the danger comment



72
73
74
75
76
77
78
79
80
81
# File 'lib/todoist/plugin.rb', line 72

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

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

  @todos
    .group_by(&:file)
    .each { |file, todos| print_todos_per_file(file, todos) }
end

#todosArray of todos

Returns the list of todos in the current diff set

Returns:



88
89
90
91
# File 'lib/todoist/plugin.rb', line 88

def todos
  find_todos if @todos.nil?
  @todos
end

#warn_for_todosvoid

This method returns an undefined value.

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



54
55
56
# File 'lib/todoist/plugin.rb', line 54

def warn_for_todos
  call_method_for_todos(:warn)
end