Commit e284fb72 authored by David Sveningsson's avatar David Sveningsson
Browse files

feat(formatters): checkstyle output is indented

parent cd0815c1
Pipeline #288033547 passed with stages
in 11 minutes and 15 seconds
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`checkstyle formatter should empty messages 1`] = `"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?><checkstyle version=\\"4.3\\"><file name=\\"empty.html\\"></file></checkstyle>"`;
exports[`checkstyle formatter should empty messages 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<checkstyle version=\\"4.3\\">
<file name=\\"empty.html\\">
</file>
</checkstyle>
"
`;
exports[`checkstyle formatter should empty result 1`] = `"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?><checkstyle version=\\"4.3\\"></checkstyle>"`;
exports[`checkstyle formatter should empty result 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<checkstyle version=\\"4.3\\">
</checkstyle>
"
`;
exports[`checkstyle formatter should generate checkstyle xml 1`] = `"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?><checkstyle version=\\"4.3\\"><file name=\\"regular.html\\"><error line=\\"1\\" column=\\"5\\" severity=\\"error\\" message=\\"An error (foo)\\" source=\\"htmlvalidate.rules.foo\\" /><error line=\\"2\\" column=\\"4\\" severity=\\"warning\\" message=\\"A warning (bar)\\" source=\\"htmlvalidate.rules.bar\\" /></file><file name=\\"edge-cases.html\\"><error line=\\"1\\" column=\\"1\\" severity=\\"error\\" message=\\"Has invalid severity (foo)\\" source=\\"htmlvalidate.rules.foo\\" /><error line=\\"2\\" column=\\"2\\" severity=\\"error\\" message=\\"Escape &lt;script language=&quot;jabbascript&quot;&gt; &amp; &lt;span id=&apos;foo&apos;&gt; (bar)\\" source=\\"htmlvalidate.rules.bar\\" /></file></checkstyle>"`;
exports[`checkstyle formatter should generate checkstyle xml 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<checkstyle version=\\"4.3\\">
<file name=\\"regular.html\\">
<error line=\\"1\\" column=\\"5\\" severity=\\"error\\" message=\\"An error (foo)\\" source=\\"htmlvalidate.rules.foo\\" />
<error line=\\"2\\" column=\\"4\\" severity=\\"warning\\" message=\\"A warning (bar)\\" source=\\"htmlvalidate.rules.bar\\" />
</file>
<file name=\\"edge-cases.html\\">
<error line=\\"1\\" column=\\"1\\" severity=\\"error\\" message=\\"Has invalid severity (foo)\\" source=\\"htmlvalidate.rules.foo\\" />
<error line=\\"2\\" column=\\"2\\" severity=\\"error\\" message=\\"Escape &lt;script language=&quot;jabbascript&quot;&gt; &amp; &lt;span id=&apos;foo&apos;&gt; (bar)\\" source=\\"htmlvalidate.rules.bar\\" />
</file>
</checkstyle>
"
`;
......@@ -29,16 +29,17 @@ function getMessageType(message: Message): "error" | "warning" {
function checkstyleFormatter(results: Result[]): string {
let output = "";
output += `<?xml version="1.0" encoding="utf-8"?>`;
output += `<checkstyle version="4.3">`;
output += `<?xml version="1.0" encoding="utf-8"?>\n`;
output += `<checkstyle version="4.3">\n`;
results.forEach((result) => {
const messages = result.messages;
output += `<file name="${xmlescape(result.filePath)}">`;
output += ` <file name="${xmlescape(result.filePath)}">\n`;
messages.forEach((message) => {
const ruleId = xmlescape(`htmlvalidate.rules.${message.ruleId}`);
output += " ";
output += [
`<error line="${xmlescape(message.line)}"`,
`column="${xmlescape(message.column)}"`,
......@@ -46,12 +47,13 @@ function checkstyleFormatter(results: Result[]): string {
`message="${xmlescape(message.message)} (${message.ruleId})"`,
`source="${ruleId}" />`,
].join(" ");
output += "\n";
});
output += "</file>";
output += " </file>\n";
});
output += "</checkstyle>";
output += "</checkstyle>\n";
return output;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment