lib/reek/cli/report/report.rb in reek-2.0.2 vs lib/reek/cli/report/report.rb in reek-2.0.3

- old
+ new

@@ -10,13 +10,17 @@ class Base DEFAULT_FORMAT = :text NO_WARNINGS_COLOR = :green WARNINGS_COLOR = :red - def initialize(_options = {}) + def initialize(options = {}) @examiners = [] @total_smell_count = 0 + @options = options + @warning_formatter = options.fetch :warning_formatter, SimpleWarningFormatter.new + @report_formatter = options.fetch :report_formatter, Formatter + @sort_by_issue_count = options.fetch :sort_by_issue_count, false end def add_examiner(examiner) @total_smell_count += examiner.smells_count @examiners << examiner @@ -34,18 +38,10 @@ # # Generates a sorted, text summary of smells in examiners # class TextReport < Base - def initialize(options = {}) - super options - @options = options - @warning_formatter = options.fetch :warning_formatter, SimpleWarningFormatter.new - @report_formatter = options.fetch :report_formatter, Formatter - @sort_by_issue_count = options.fetch :sort_by_issue_count, false - end - def show sort_examiners if smells? display_summary display_total_smell_count end @@ -105,10 +101,14 @@ # # Displays a list of smells in JSON format # JSON with empty array for 0 smells class JsonReport < Base def show - print ::JSON.generate(smells.map(&:yaml_hash)) + print ::JSON.generate( + smells.map do |smell| + smell.yaml_hash(@warning_formatter) + end + ) end end # # Saves the report as a HTML file