Module: Moku6::Reporter::Markdown
- Defined in:
- lib/moku6/reporter.rb
Overview
Review-friendly Markdown report (e.g. for posting as a PR comment).
Class Method Summary collapse
-
.render(result) ⇒ Object
: (Result result) -> String.
-
.report(result) ⇒ Object
: (Result result) -> void.
- .section(title, offenses) ⇒ Object
Class Method Details
.render(result) ⇒ Object
: (Result result) -> String
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/moku6/reporter.rb', line 44 def self.render(result) errors = result.errors warnings = result.warnings out = ["# Audit catalog report", ""] if result.empty? out << "No issues detected. ✅" return out.join("\n") + "\n" end out << "**#{errors.size} error#{"s" if errors.size != 1}, " \ "#{warnings.size} warning#{"s" if warnings.size != 1}** detected." out.concat(section("❌ Errors", errors)) out.concat(section("⚠️ Warnings", warnings)) out.join("\n") + "\n" end |
.report(result) ⇒ Object
: (Result result) -> void
41 |
# File 'lib/moku6/reporter.rb', line 41 def self.report(result) = puts render(result) |
.section(title, offenses) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/moku6/reporter.rb', line 60 def self.section(title, offenses) return [] if offenses.empty? lines = ["", "## #{title}", ""] offenses.each do |o| lines << "- `#{o.action}` — #{o.} (`#{o.file}`)" end lines end |