Skip to content

Commit

Permalink
Add linter name to TAP YAML
Browse files Browse the repository at this point in the history
Including this information in the YAML will make the output of these
errors and warnings easier for people to parse and work with.
  • Loading branch information
lencioni committed Mar 2, 2016
1 parent 338fcd4 commit b9ca3be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/scss_lint/reporter/tap_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,25 @@ def format_ok(file, test_number)
def format_not_ok(lint, test_number)
location = lint.location
test_line_description = "#{lint.filename}:#{location.line}:#{location.column}"
test_line_description += " #{lint.linter.name}" if lint.linter

data = {
'message' => lint.description,
'severity' => lint.severity.to_s,
'file' => lint.filename,
'line' => lint.location.line,
'column' => lint.location.column,
}

if lint.linter
test_line_description += " #{lint.linter.name}" if lint.linter
data['name'] = lint.linter.name
end

data_yaml = data.to_yaml.strip.gsub(/^/, ' ')

<<-EOS.strip
not ok #{test_number} - #{test_line_description}
---
message: #{lint.description}
severity: #{lint.severity}
file: #{lint.filename}
line: #{lint.location.line}
column: #{lint.location.column}
#{data_yaml}
...
EOS
end
Expand Down
3 changes: 3 additions & 0 deletions spec/scss_lint/reporter/tap_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
file: not-ok1.scss
line: 123
column: 10
name: SCSSLint::Linter::PrivateNamingConvention
...
not ok 3 - not-ok2.scss:20:2 SCSSLint::Linter::PrivateNamingConvention
---
Expand All @@ -78,6 +79,7 @@
file: not-ok2.scss
line: 20
column: 2
name: SCSSLint::Linter::PrivateNamingConvention
...
not ok 4 - not-ok2.scss:21:3 SCSSLint::Linter::PrivateNamingConvention
---
Expand All @@ -86,6 +88,7 @@
file: not-ok2.scss
line: 21
column: 3
name: SCSSLint::Linter::PrivateNamingConvention
...
ok 5 - ok2.scss
EOS
Expand Down

0 comments on commit b9ca3be

Please sign in to comment.