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 at or above 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: nil) ⇒ 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: nil) ⇒ Report
Creates a report.
21 22 23 24 25 26 |
# File 'lib/haml_lint/report.rb', line 21 def initialize(lints: [], files: [], fail_level: :warning, reporter: nil) @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
10 11 12 |
# File 'lib/haml_lint/report.rb', line 10 def fail_level @fail_level end |
#files ⇒ Object (readonly)
List of files that were linted.
13 14 15 |
# File 'lib/haml_lint/report.rb', line 13 def files @files end |
#lints ⇒ Object
List of lints that were found.
7 8 9 |
# File 'lib/haml_lint/report.rb', line 7 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.
32 33 34 35 |
# File 'lib/haml_lint/report.rb', line 32 def add_lint(lint) lints << lint @reporter.added_lint(lint, self) end |
#display ⇒ void
This method returns an undefined value.
Displays the report via the configured reporter.
40 41 42 |
# File 'lib/haml_lint/report.rb', line 40 def display @reporter.display_report(self) end |
#failed? ⇒ Boolean
Checks whether any lints were at or above the fail level
47 48 49 |
# File 'lib/haml_lint/report.rb', line 47 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.
56 57 58 59 |
# File 'lib/haml_lint/report.rb', line 56 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.
65 66 67 |
# File 'lib/haml_lint/report.rb', line 65 def start(files) @reporter.start(files) end |