Skip to content

Commit 5872d51

Browse files
committed
Dangerfile: handle html5validator output.
1 parent 1596301 commit 5872d51

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Dangerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,34 @@ else
279279
end
280280
end
281281

282+
# Handle `html5validator` output
283+
#
284+
# Example:
285+
# 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.
286+
# "file:/home/coder/mystamps/src/main/webapp/WEB-INF/views/series/info.html":438.16-438.35: error: very long err msg.
287+
#
288+
validator_output = 'validator.log'
289+
unless File.file?(validator_output)
290+
warn("Couldn't find #{validator_output}. html5validator result is unknown")
291+
else
292+
errors_count = 0
293+
File.readlines(validator_output).each do |line|
294+
errors_count += 1
295+
line.sub!(/^WARNING:html5validator.validator:/, '')
296+
297+
parsed = line.match(/^"file:(?<file>[^"]+)":(?<line>\d+)[^:]+: error: (?<msg>.+)/)
298+
msg = parsed['msg'].sub(/\.$/, '')
299+
file = parsed['file'].sub(pwd, '')
300+
lineno = parsed['line']
301+
file = github.html_link("#{file}#L#{lineno}")
302+
303+
fail("html5validator error in #{file}:\n#{msg}")
304+
end
305+
306+
# TODO: add link to wiki page (#541)
307+
print_errors_summary 'html5validator', errors_count
308+
end
309+
282310
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:compile` output
283311
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:testCompile` output
284312
# Handle `mvn org.codehaus.gmaven:gmaven-plugin:testCompile` output

0 commit comments

Comments
 (0)