Skip to content

Commit b733cb9

Browse files
committed
Dangerfile: handle html5validator output.
1 parent a6dfe08 commit b733cb9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Dangerfile

+28
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,34 @@ else
329329
end
330330
end
331331

332+
# Handle `html5validator` output
333+
#
334+
# Example:
335+
# WARNING:html5validator.validator:"file:/home/coder/mystamps/src/main/webapp/WEB-INF/views/series/info.html":110.11-114.58: error: very long err msg.
336+
# "file:/home/coder/mystamps/src/main/webapp/WEB-INF/views/series/info.html":438.16-438.35: error: very long err msg.
337+
#
338+
validator_output = 'validator.log'
339+
unless File.file?(validator_output)
340+
warn("Couldn't find #{validator_output}. html5validator result is unknown")
341+
else
342+
errors_count = 0
343+
File.readlines(validator_output).each do |line|
344+
errors_count += 1
345+
line.sub!(/^WARNING:html5validator.validator:/, '')
346+
347+
parsed = line.match(/^"file:(?<file>[^"]+)":(?<line>\d+)[^:]+: error: (?<msg>.+)/)
348+
msg = parsed['msg'].sub(/\.$/, '')
349+
file = parsed['file'].sub(pwd, '')
350+
lineno = parsed['line']
351+
file = github.html_link("#{file}#L#{lineno}")
352+
353+
fail("html5validator error in #{file}:\n#{msg}")
354+
end
355+
356+
# TODO: add link to wiki page (#541)
357+
print_errors_summary 'html5validator', errors_count
358+
end
359+
332360
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:compile` output
333361
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:testCompile` output
334362
# Handle `mvn org.codehaus.gmaven:gmaven-plugin:testCompile` output

0 commit comments

Comments
 (0)