Class: LintTrappings::Report
- Inherits:
-
Object
- Object
- LintTrappings::Report
- Defined in:
- lib/lint_trappings/report.rb
Overview
Contains information about all lints detected during a scan.
Instance Attribute Summary collapse
-
#documents_inspected ⇒ Array<String>
readonly
List of files that were inspected.
-
#lints ⇒ Array<LintTrappings::Lint]
List of lints that were found.
Instance Method Summary collapse
- #fail_severities ⇒ Object
- #failures ⇒ Object
- #failures? ⇒ Boolean
-
#initialize(config, lints, documents) ⇒ Report
constructor
A new instance of Report.
- #severities ⇒ Object
- #success? ⇒ Boolean
- #warn_severities ⇒ Object
- #warnings ⇒ Object
- #warnings? ⇒ Boolean
Constructor Details
#initialize(config, lints, documents) ⇒ Report
Returns a new instance of Report.
14 15 16 17 18 |
# File 'lib/lint_trappings/report.rb', line 14 def initialize(config, lints, documents) @config = config @lints = lints.sort_by { |lint| [lint.path, lint.source_range.begin.line] } @documents_inspected = documents end |
Instance Attribute Details
#documents_inspected ⇒ Array<String> (readonly)
Returns List of files that were inspected.
9 10 11 |
# File 'lib/lint_trappings/report.rb', line 9 def documents_inspected @documents_inspected end |
#lints ⇒ Array<LintTrappings::Lint]
List of lints that were found.
6 7 8 |
# File 'lib/lint_trappings/report.rb', line 6 def lints @lints end |
Instance Method Details
#fail_severities ⇒ Object
24 25 26 |
# File 'lib/lint_trappings/report.rb', line 24 def fail_severities @fail_severities ||= severities.select { |_severity, action| action == 'fail' }.keys end |
#failures ⇒ Object
36 37 38 39 40 41 |
# File 'lib/lint_trappings/report.rb', line 36 def failures @failures ||= begin @lints.select { |lint| fail_severities.include?(lint.severity) } end end |
#failures? ⇒ Boolean
32 33 34 |
# File 'lib/lint_trappings/report.rb', line 32 def failures? failures.any? end |
#severities ⇒ Object
20 21 22 |
# File 'lib/lint_trappings/report.rb', line 20 def severities @severities ||= @config.fetch('severities', error: 'fail', warning: 'warn') end |
#success? ⇒ Boolean
54 55 56 |
# File 'lib/lint_trappings/report.rb', line 54 def success? lints.empty? end |
#warn_severities ⇒ Object
28 29 30 |
# File 'lib/lint_trappings/report.rb', line 28 def warn_severities @warn_severities ||= severities.select { |_severity, action| action == 'warn' }.keys end |
#warnings ⇒ Object
47 48 49 50 51 52 |
# File 'lib/lint_trappings/report.rb', line 47 def warnings @warnings ||= begin @lints.select { |lint| warn_severities.include?(lint.severity) } end end |
#warnings? ⇒ Boolean
43 44 45 |
# File 'lib/lint_trappings/report.rb', line 43 def warnings? warnings.any? end |