lib/htmllint/plugin.rb in danger-htmllint-0.1.0 vs lib/htmllint/plugin.rb in danger-htmllint-0.1.1
- old
+ new
@@ -52,27 +52,32 @@
def target_files
((git.modified_files - git.deleted_files) + git.added_files)
end
def parse(result)
- result.split("\n").flat_map do |item|
+ list = []
+ result.split("\n").each do |item|
+ next if item == ""
+
path_and_err = item.split(":")
- break if path_and_err.empty?
+ next if path_and_err.length < 2
file_path = path_and_err.first
line_col_err_msg = path_and_err.last.split(", ")
line = line_col_err_msg[0].sub("line ", "").to_i
col = line_col_err_msg[1].sub("col ", "")
err_msg = line_col_err_msg[2]
- {
+ list << {
file_path: file_path,
line: line,
severity: severity_level(fail_on_error),
message: "#{err_msg} (col:#{col})"
}
end
+
+ list
end
def severity_level(fail_on_error)
fail_on_error ? "fail" : "warn"
end