class SCSSLint::Reporter::JSONReporter

Reports lints in a JSON format.

Public Instance Methods

report_lints() click to toggle source
# File lib/scss_lint/reporter/json_reporter.rb, line 6
def report_lints
  output = {}
  lints.group_by(&:filename).each do |filename, file_lints|
    output[filename] = file_lints.map do |lint|
      issue_hash(lint)
    end
  end
  JSON.pretty_generate(output)
end

Private Instance Methods

issue_hash(lint) click to toggle source
# File lib/scss_lint/reporter/json_reporter.rb, line 18
def issue_hash(lint)
  {
    'line' => lint.location.line,
    'column' => lint.location.column,
    'length' => lint.location.length,
    'severity' => lint.severity,
    'reason' => lint.description,
  }.tap do |hash|
    hash['linter'] = lint.linter.name if lint.linter
  end
end