class HamlLint::Report
Contains information about all lints detected during a scan.
Attributes
The level of lint to fail after detecting
List of files that were linted.
List of lints that were found.
Public Class Methods
Creates a report.
@param lints [Array<HamlLint::Lint>] lints that were found @param files [Array<String>] files that were linted @param #fail_level [Symbol] the severity level to fail on @param reporter [HamlLint::Reporter] the reporter for the report
# File lib/haml_lint/report.rb, line 20 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
Public Instance Methods
Adds a lint to the report and notifies the reporter.
@param lint [HamlLint::Lint] lint to add @return [void]
# File lib/haml_lint/report.rb, line 31 def add_lint(lint) lints << lint @reporter.added_lint(lint, self) end
Displays the report via the configured reporter.
@return [void]
# File lib/haml_lint/report.rb, line 39 def display @reporter.display_report(self) end
Checks whether any lints were at or above the fail level
@return [Boolean]
# File lib/haml_lint/report.rb, line 46 def failed? @lints.any? { |lint| lint.severity >= fail_level } end
Adds a file to the list of linted files and notifies the reporter.
@param file [String] the name of the file that was finished @param lints [Array<HamlLint::Lint>] the lints for the finished file @return [void]
# File lib/haml_lint/report.rb, line 55 def finish_file(file, lints) files << file @reporter.finished_file(file, lints) end
Notifies the reporter that the report has started.
@param files [Array<String>] the files to lint @return [void]
# File lib/haml_lint/report.rb, line 64 def start(files) @reporter.start(files) end