Class: TodoLint::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/todo_lint/reporter.rb

Overview

We want to be able to report to users about the todos in their code, and the Reporter is responsible for passing judgment and generating output

Instance Method Summary collapse

Constructor Details

#initialize(todo, judge: RequiredArg.new) ⇒ Reporter

Accept a todo and a path to check for problems

Examples:

Reporter.new(todo,
  judge: Judge.new(todo))


10
11
12
13
14
# File 'lib/todo_lint/reporter.rb', line 10

def initialize(todo, judge: RequiredArg.new)
  @todo = todo
  @path = todo.path
  @judge = judge
end

Instance Method Details

#reportString, NilClass

Generate the output to show the user about their todo

Examples:

reporter.report

Returns:

  • (String)

    if the todo is problematic

  • (NilClass)

    if the todo is fine



22
23
24
25
26
27
28
# File 'lib/todo_lint/reporter.rb', line 22

def report
  return if judge.charge.nil?

  "#{todo_location} #{problem}\n" \
  "#{todo.line.chomp.lstrip}\n" \
  "#{spaces}#{carets}"
end