Class: HamlLint::Report
- Inherits:
-
Object
- Object
- HamlLint::Report
- Defined in:
- lib/haml_lint/report.rb
Overview
Contains information about all lints detected during a scan.
Instance Attribute Summary collapse
-
#fail_level ⇒ Object
readonly
The level of lint to fail after detecting.
-
#files ⇒ Object
readonly
List of files that were linted.
-
#lints ⇒ Object
List of lints that were found.
Instance Method Summary collapse
-
#add_lint(lint) ⇒ void
Adds a lint to the report and notifies the reporter.
-
#display ⇒ void
Displays the report via the configured reporter.
-
#failed? ⇒ Boolean
Checks whether any lints were over the fail level.
-
#finish_file(file, lints) ⇒ void
Adds a file to the list of linted files and notifies the reporter.
-
#initialize(lints = [], files = [], fail_level = :warning, reporter:) ⇒ Report
constructor
Creates a report.
-
#start(files) ⇒ void
Notifies the reporter that the report has started.
Constructor Details
#initialize(lints = [], files = [], fail_level = :warning, reporter:) ⇒ Report
Creates a report.
19 20 21 22 23 24 |
# File 'lib/haml_lint/report.rb', line 19 def initialize(lints = [], files = [], fail_level = :warning, reporter:) @lints = lints.sort_by { |l| [l.filename, l.line] } @files = files @fail_level = Severity.new(fail_level) @reporter = reporter end |
Instance Attribute Details
#fail_level ⇒ Object (readonly)
The level of lint to fail after detecting
8 9 10 |
# File 'lib/haml_lint/report.rb', line 8 def fail_level @fail_level end |
#files ⇒ Object (readonly)
List of files that were linted.
11 12 13 |
# File 'lib/haml_lint/report.rb', line 11 def files @files end |
#lints ⇒ Object
List of lints that were found.
5 6 7 |
# File 'lib/haml_lint/report.rb', line 5 def lints @lints end |
Instance Method Details
#add_lint(lint) ⇒ void
This method returns an undefined value.
Adds a lint to the report and notifies the reporter.
30 31 32 33 |
# File 'lib/haml_lint/report.rb', line 30 def add_lint(lint) lints << lint @reporter.added_lint(lint) end |
#display ⇒ void
This method returns an undefined value.
Displays the report via the configured reporter.
38 39 40 |
# File 'lib/haml_lint/report.rb', line 38 def display @reporter.display_report(self) end |
#failed? ⇒ Boolean
Checks whether any lints were over the fail level
45 46 47 |
# File 'lib/haml_lint/report.rb', line 45 def failed? @lints.any? { |lint| lint.severity >= fail_level } end |
#finish_file(file, lints) ⇒ void
This method returns an undefined value.
Adds a file to the list of linted files and notifies the reporter.
54 55 56 57 |
# File 'lib/haml_lint/report.rb', line 54 def finish_file(file, lints) files << file @reporter.finished_file(file, lints) end |
#start(files) ⇒ void
This method returns an undefined value.
Notifies the reporter that the report has started.
63 64 65 |
# File 'lib/haml_lint/report.rb', line 63 def start(files) @reporter.start(files) end |