Class: Reek::Report::BaseReport Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/report/base_report.rb

Overview

This class is abstract.

Subclass and override #show to create a concrete report class.

A report that contains the smells and smell counts following source code analysis.

Constant Summary collapse

NO_WARNINGS_COLOR =
:green
WARNINGS_COLOR =
:red

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(heading_formatter: QuietHeadingFormatter, sort_by_issue_count: false, warning_formatter: SimpleWarningFormatter.new, progress_formatter: ProgressFormatter::Quiet.new(0)) ⇒ BaseReport

Returns a new instance of BaseReport.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/reek/report/base_report.rb', line 25

def initialize(heading_formatter: QuietHeadingFormatter,
               sort_by_issue_count: false,
               warning_formatter: SimpleWarningFormatter.new,
               progress_formatter: ProgressFormatter::Quiet.new(0))
  @examiners           = []
  @heading_formatter   = heading_formatter.new
  @progress_formatter  = progress_formatter
  @sort_by_issue_count = sort_by_issue_count
  @total_smell_count   = 0
  @warning_formatter   = warning_formatter
end

Instance Attribute Details

#examinersObject (readonly, private)

Returns the value of attribute examiners.



70
71
72
# File 'lib/reek/report/base_report.rb', line 70

def examiners
  @examiners
end

#heading_formatterObject (readonly, private)

Returns the value of attribute heading_formatter.



70
71
72
# File 'lib/reek/report/base_report.rb', line 70

def heading_formatter
  @heading_formatter
end

#progress_formatterObject (readonly, private)

Returns the value of attribute progress_formatter.



70
71
72
# File 'lib/reek/report/base_report.rb', line 70

def progress_formatter
  @progress_formatter
end

#sort_by_issue_countObject (readonly, private)

Returns the value of attribute sort_by_issue_count.



70
71
72
# File 'lib/reek/report/base_report.rb', line 70

def sort_by_issue_count
  @sort_by_issue_count
end

#warning_formatterObject (readonly, private)

Returns the value of attribute warning_formatter.



70
71
72
# File 'lib/reek/report/base_report.rb', line 70

def warning_formatter
  @warning_formatter
end

Instance Method Details

#add_examiner(examiner) ⇒ Object

Add Examiner to report on. The report will output results for all added examiners.

Parameters:



43
44
45
46
47
# File 'lib/reek/report/base_report.rb', line 43

def add_examiner(examiner)
  self.total_smell_count += examiner.smells_count
  examiners << examiner
  self
end

#showObject

Render the report results on STDOUT

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/reek/report/base_report.rb', line 52

def show
  raise NotImplementedError
end

#smellsObject



60
61
62
# File 'lib/reek/report/base_report.rb', line 60

def smells
  examiners.map(&:smells).flatten
end

#smells?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/reek/report/base_report.rb', line 56

def smells?
  total_smell_count.positive?
end