class HamlLint::Report

Contains information about all lints detected during a scan.

Attributes

fail_level[R]

The level of lint to fail after detecting

files[R]

List of files that were linted.

lints[RW]

List of lints that were found.

Public Class Methods

new(lints: [], files: [], fail_level: :warning, reporter: nil) click to toggle source

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 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

Public Instance Methods

add_lint(lint) click to toggle source

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 32
def add_lint(lint)
  lints << lint
  @reporter.added_lint(lint, self)
end
display() click to toggle source

Displays the report via the configured reporter.

@return [void]

# File lib/haml_lint/report.rb, line 40
def display
  @reporter.display_report(self)
end
failed?() click to toggle source

Checks whether any lints were at or above the fail level

@return [Boolean]

# File lib/haml_lint/report.rb, line 47
def failed?
  @lints.any? { |lint| lint.severity >= fail_level }
end
finish_file(file, lints) click to toggle source

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 56
def finish_file(file, lints)
  files << file
  @reporter.finished_file(file, lints)
end
start(files) click to toggle source

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 65
def start(files)
  @reporter.start(files)
end