lib/scss_lint/reporter/json_reporter.rb in scss-lint-0.30.0 vs lib/scss_lint/reporter/json_reporter.rb in scss-lint-0.31.0
- old
+ new
@@ -5,19 +5,26 @@
class Reporter::JSONReporter < Reporter
def report_lints
output = {}
lints.group_by(&:filename).each do |filename, file_lints|
output[filename] = file_lints.map do |lint|
- issue = {}
- issue['linter'] = lint.linter.name if lint.linter
- issue['line'] = lint.location.line
- issue['column'] = lint.location.column
- issue['length'] = lint.location.length
- issue['severity'] = lint.severity
- issue['reason'] = lint.description
- issue
+ issue_hash(lint)
end
end
JSON.pretty_generate(output)
+ end
+
+ private
+
+ 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
end
end