Class: Reek::Report::BaseReport Abstract
- Inherits:
-
Object
- Object
- Reek::Report::BaseReport
- Defined in:
- lib/reek/report/base_report.rb
Overview
Subclass and override #show to create a concrete report class.
A report that contains the smells and smell counts following source code analysis.
Direct Known Subclasses
CodeClimate::CodeClimateReport, GithubReport, HTMLReport, JSONReport, TextReport, XMLReport, YAMLReport
Constant Summary collapse
- NO_WARNINGS_COLOR =
:green
- WARNINGS_COLOR =
:red
Instance Attribute Summary collapse
-
#examiners ⇒ Object
readonly
private
Returns the value of attribute examiners.
-
#heading_formatter ⇒ Object
readonly
private
Returns the value of attribute heading_formatter.
-
#progress_formatter ⇒ Object
readonly
private
Returns the value of attribute progress_formatter.
-
#sort_by_issue_count ⇒ Object
readonly
private
Returns the value of attribute sort_by_issue_count.
-
#warning_formatter ⇒ Object
readonly
private
Returns the value of attribute warning_formatter.
Instance Method Summary collapse
-
#add_examiner(examiner) ⇒ Object
Add Examiner to report on.
-
#initialize(heading_formatter: QuietHeadingFormatter, sort_by_issue_count: false, warning_formatter: SimpleWarningFormatter.new, progress_formatter: ProgressFormatter::Quiet.new(0)) ⇒ BaseReport
constructor
A new instance of BaseReport.
-
#show ⇒ Object
Render the report results on STDOUT.
- #smells ⇒ Object
- #smells? ⇒ Boolean
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
#examiners ⇒ Object (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_formatter ⇒ Object (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_formatter ⇒ Object (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_count ⇒ Object (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_formatter ⇒ Object (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.
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 |
#show ⇒ Object
Render the report results on STDOUT
52 53 54 |
# File 'lib/reek/report/base_report.rb', line 52 def show raise NotImplementedError end |
#smells ⇒ Object
60 61 62 |
# File 'lib/reek/report/base_report.rb', line 60 def smells examiners.map(&:smells).flatten end |
#smells? ⇒ Boolean
56 57 58 |
# File 'lib/reek/report/base_report.rb', line 56 def smells? total_smell_count.positive? end |