"<body>\n" + //$NON-NLS-1$
"<h1>" + //$NON-NLS-1$
"Lint Report" +
"</h1>"); //$NON-NLS-1$
Issue previousIssue = null;
if (issues.size() > 0) {
List<List<Warning>> related = new ArrayList<List<Warning>>();
List<Warning> currentList = null;
for (Warning warning : issues) {
if (warning.issue != previousIssue) {
previousIssue = warning.issue;
currentList = new ArrayList<Warning>();
related.add(currentList);
}
assert currentList != null;
currentList.add(warning);
}
mWriter.write(String.format("Check performed at %1$s.",
new Date().toString()));
mWriter.write("<br/><br/>"); //$NON-NLS-1$
mWriter.write(String.format("%1$d errors and %2$d warnings found:",
errorCount, warningCount));
mWriter.write("<br/>"); //$NON-NLS-1$
// Write issue id summary
mWriter.write("<ul>\n"); //$NON-NLS-1$
Category previousCategory = null;
for (List<Warning> warnings : related) {
Issue issue = warnings.get(0).issue;
if (issue.getCategory() != previousCategory) {
if (previousCategory != null) {
mWriter.write("</ul>\n"); //$NON-NLS-1$
}
previousCategory = issue.getCategory();
String categoryName = issue.getCategory().getFullName();
mWriter.write("<li> <a href=\"#"); //$NON-NLS-1$
mWriter.write(categoryName);
mWriter.write("\">"); //$NON-NLS-1$
mWriter.write(categoryName);
mWriter.write("</a>\n"); //$NON-NLS-1$
mWriter.write("\n<ul>\n"); //$NON-NLS-1$
}
mWriter.write("<li> <a href=\"#"); //$NON-NLS-1$
mWriter.write(issue.getId());
mWriter.write("\">"); //$NON-NLS-1$
mWriter.write(String.format("%1$3d %2$s", //$NON-NLS-1$
warnings.size(), issue.getId()));
mWriter.write("</a>\n"); //$NON-NLS-1$
}
if (previousCategory != null) {
mWriter.write("</ul>\n"); //$NON-NLS-1$
}
mWriter.write("</ul>\n"); //$NON-NLS-1$
mWriter.write("<br/>"); //$NON-NLS-1$
previousCategory = null;
for (List<Warning> warnings : related) {
Warning first = warnings.get(0);
Issue issue = first.issue;
if (issue.getCategory() != previousCategory) {
previousCategory = issue.getCategory();
mWriter.write("\n<a name=\""); //$NON-NLS-1$
mWriter.write(issue.getCategory().getFullName());
mWriter.write("\">\n"); //$NON-NLS-1$
mWriter.write("<div class=\"category\">"); //$NON-NLS-1$
mWriter.write(issue.getCategory().getFullName());
mWriter.write("</div>\n"); //$NON-NLS-1$
}
mWriter.write("<a name=\"" + issue.getId() + "\">\n"); //$NON-NLS-1$ //$NON-NLS-2$
mWriter.write("<div class=\"issue\">\n"); //$NON-NLS-1$
// Explain this issue
mWriter.write("<div class=\"id\">"); //$NON-NLS-1$
mWriter.write(issue.getId());
mWriter.write("</div>\n"); //$NON-NLS-1$
mWriter.write("<div class=\"warningslist\">\n"); //$NON-NLS-1$
boolean partialHide = !mSimpleFormat && warnings.size() > SPLIT_LIMIT;
int count = 0;
for (Warning warning : warnings) {
if (partialHide && count == SHOWN_COUNT) {
String id = warning.issue.getId() + "Div"; //$NON-NLS-1$
mWriter.write("<input id=\""); //$NON-NLS-1$
mWriter.write(id);
mWriter.write("Link\" onclick=\"reveal('"); //$NON-NLS-1$
mWriter.write(id);
mWriter.write("');\" type=\"button\" value=\""); //$NON-NLS-1$
mWriter.write(String.format("+ %1$d More...",
warnings.size() - SHOWN_COUNT));
mWriter.write("\" />\n"); //$NON-NLS-1$
mWriter.write("<div id=\""); //$NON-NLS-1$
mWriter.write(id);
mWriter.write("\" style=\"display: none\">\n"); //$NON-NLS-1$
}
count++;
String url = null;
if (warning.path != null) {
mWriter.write("<span class=\"location\">"); //$NON-NLS-1$
url = getUrl(warning.file);
if (url != null) {
mWriter.write("<a href=\""); //$NON-NLS-1$
mWriter.write(url);
mWriter.write("\">"); //$NON-NLS-1$
}
mWriter.write(warning.path);
if (url != null) {
mWriter.write("</a>"); //$NON-NLS-1$
}
mWriter.write(':');
if (warning.line >= 0) {
// 0-based line numbers, but display 1-based
mWriter.write(Integer.toString(warning.line + 1) + ':');
}
mWriter.write("</span>"); //$NON-NLS-1$
mWriter.write(' ');
}
// Is the URL for a single image? If so, place it here near the top
// of the error floating on the right. If there are multiple images,
// they will instead be placed in a horizontal box below the error
boolean addedImage = false;
if (url != null && warning.location != null
&& warning.location.getSecondary() == null) {
addedImage = addImage(url, warning.location);
}
mWriter.write("<span class=\"message\">"); //$NON-NLS-1$
appendEscapedText(warning.message);
mWriter.write("</span>"); //$NON-NLS-1$
if (addedImage) {
mWriter.write("<br clear=\"right\"/>"); //$NON-NLS-1$
} else {
mWriter.write("<br />"); //$NON-NLS-1$
}
// Insert surrounding code block window
if (warning.line >= 0 && warning.fileContents != null) {
mWriter.write("<pre class=\"errorlines\">\n"); //$NON-NLS-1$
appendCodeBlock(warning.fileContents, warning.line, warning.offset);
mWriter.write("\n</pre>"); //$NON-NLS-1$
}
mWriter.write('\n');
// Place a block of images?
if (!addedImage && url != null && warning.location != null
&& warning.location.getSecondary() != null) {
addImage(url, warning.location);
}
}
if (partialHide) { // Close up the extra div
mWriter.write("</div>\n"); //$NON-NLS-1$
}
mWriter.write("</div>\n"); //$NON-NLS-1$
mWriter.write("<div class=\"metadata\">"); //$NON-NLS-1$
mWriter.write("Priority: ");
mWriter.write(String.format("%1$d / 10", issue.getPriority()));
mWriter.write("<br/>\n"); //$NON-NLS-1$
mWriter.write("Category: ");
mWriter.write(issue.getCategory().getFullName());
mWriter.write("</div>\n"); //$NON-NLS-1$
mWriter.write("Severity: ");
if (first.severity == Severity.ERROR) {
mWriter.write("<span class=\"error\">"); //$NON-NLS-1$
} else if (first.severity == Severity.WARNING) {
mWriter.write("<span class=\"warning\">"); //$NON-NLS-1$
} else {
mWriter.write("<span>"); //$NON-NLS-1$
}
appendEscapedText(first.severity.getDescription());
mWriter.write("</span>"); //$NON-NLS-1$
mWriter.write("<div class=\"summary\">\n"); //$NON-NLS-1$
mWriter.write("Explanation: ");
String description = issue.getDescription();
mWriter.write(description);
if (description.length() > 0
&& Character.isLetter(description.charAt(description.length() - 1))) {
mWriter.write('.');
}
mWriter.write("</div>\n"); //$NON-NLS-1$
mWriter.write("<div class=\"explanation\">\n"); //$NON-NLS-1$
String explanation = issue.getExplanation();
explanation = explanation.replace("\n", "<br/>"); //$NON-NLS-1$ //$NON-NLS-2$
explanation = Main.wrap(explanation);
appendEscapedText(explanation);
mWriter.write("\n</div>\n"); //$NON-NLS-1$;
if (issue.getMoreInfo() != null) {
mWriter.write("<div class=\"moreinfo\">"); //$NON-NLS-1$
mWriter.write("More info: ");
mWriter.write("<a href=\""); //$NON-NLS-1$
mWriter.write(issue.getMoreInfo());
mWriter.write("\">"); //$NON-NLS-1$
mWriter.write(issue.getMoreInfo());
mWriter.write("</a></div>\n"); //$NON-NLS-1$
}
mWriter.write("<br/>"); //$NON-NLS-1$
mWriter.write("To suppress this error, run lint with <code>--ignore ");
mWriter.write(issue.getId());
mWriter.write("</code><br/>"); //$NON-NLS-1$
mWriter.write("</div>"); //$NON-NLS-1$
}
}