diff options
author | Tor Norbye <tnorbye@google.com> | 2012-02-06 09:58:35 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-02-06 14:33:08 -0800 |
commit | fdb40f1180f7be98c38d5b1e193a737f90ca1f72 (patch) | |
tree | 53ded89e19fccec0a657d29a2293761c83b4dc26 /lint | |
parent | 691cd5e9dc9167e15bb431e88286f4086553281e (diff) | |
download | sdk-fdb40f1180f7be98c38d5b1e193a737f90ca1f72.zip sdk-fdb40f1180f7be98c38d5b1e193a737f90ca1f72.tar.gz sdk-fdb40f1180f7be98c38d5b1e193a737f90ca1f72.tar.bz2 |
HTML report tweaks
- If specifying a report directory (rather than an HTML file name),
always write out an overview report. (Before this it only wrote an
overview report if issues were *found* in multiple projects).
- If checking *specific* issues (with the --check flag), don't write out
the list of suppressed issues.
- If no errors were found, write a message to that effect.
- Make some space between the explanation area and the More Info URL,
if any
- Code cleanup
Change-Id: I0c1a5cf14de15276904e8999323df443fc39dc9c
Diffstat (limited to 'lint')
3 files changed, 58 insertions, 53 deletions
diff --git a/lint/cli/src/com/android/tools/lint/HtmlReporter.java b/lint/cli/src/com/android/tools/lint/HtmlReporter.java index 04abeb8..45aac72 100644 --- a/lint/cli/src/com/android/tools/lint/HtmlReporter.java +++ b/lint/cli/src/com/android/tools/lint/HtmlReporter.java @@ -111,6 +111,13 @@ class HtmlReporter extends Reporter { "<div class=\"titleSeparator\"></div>\n" + //$NON-NLS-1$ "</h1>\n"); //$NON-NLS-1$ + mWriter.write(String.format("Check performed at %1$s.", + new Date().toString())); + mWriter.write("<br/>"); //$NON-NLS-1$ + mWriter.write(String.format("%1$d errors and %2$d warnings found:", + errorCount, warningCount)); + mWriter.write("<br/><br/>"); //$NON-NLS-1$ + Issue previousIssue = null; if (issues.size() > 0) { List<List<Warning>> related = new ArrayList<List<Warning>>(); @@ -125,14 +132,6 @@ class HtmlReporter extends Reporter { currentList.add(warning); } - mWriter.write(String.format("Check performed at %1$s.", - new Date().toString())); - mWriter.write("<br/>"); //$NON-NLS-1$ - mWriter.write(String.format("%1$d errors and %2$d warnings found:", - errorCount, warningCount)); - mWriter.write("<br/><br/>"); //$NON-NLS-1$ - - writeOverview(related, missing.size()); Category previousCategory = null; @@ -292,9 +291,13 @@ class HtmlReporter extends Reporter { writeIssueMetadata(issue, first.severity, null); } - writeMissingIssues(missing); + if (!mClient.isCheckingSpecificIssues()) { + writeMissingIssues(missing); + } writeSuppressInfo(); + } else { + mWriter.write("Congratulations!"); } mWriter.write("\n</body>\n</html>"); //$NON-NLS-1$ mWriter.close(); @@ -355,6 +358,7 @@ class HtmlReporter extends Reporter { appendEscapedText(explanation, true /* preserve newlines*/); mWriter.write("\n</div>\n"); //$NON-NLS-1$; if (issue.getMoreInfo() != null) { + mWriter.write("<br/>"); //$NON-NLS-1$ mWriter.write("<div class=\"moreinfo\">"); //$NON-NLS-1$ mWriter.write("More info: "); mWriter.write("<a href=\""); //$NON-NLS-1$ @@ -546,7 +550,7 @@ class HtmlReporter extends Reporter { mWriter.write("</td></tr>\n"); } - if (missingCount > 0) { + if (missingCount > 0 && !mClient.isCheckingSpecificIssues()) { mWriter.write("<tr><td></td>"); //$NON-NLS-1$ mWriter.write("<td class=\"categoryColumn\">"); //$NON-NLS-1$ mWriter.write("<a href=\"#MissingIssues\">"); //$NON-NLS-1$ diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java index e818b6a..ae1aa36 100644 --- a/lint/cli/src/com/android/tools/lint/Main.java +++ b/lint/cli/src/com/android/tools/lint/Main.java @@ -952,6 +952,10 @@ public class Main extends LintClient { } } + boolean isCheckingSpecificIssues() { + return mCheck != null; + } + /** * Consult the lint.xml file, but override with the --enable and --disable * flags supplied on the command line diff --git a/lint/cli/src/com/android/tools/lint/MultiProjectHtmlReporter.java b/lint/cli/src/com/android/tools/lint/MultiProjectHtmlReporter.java index d7d62f2..6dad258 100644 --- a/lint/cli/src/com/android/tools/lint/MultiProjectHtmlReporter.java +++ b/lint/cli/src/com/android/tools/lint/MultiProjectHtmlReporter.java @@ -24,7 +24,6 @@ import com.google.common.io.Closeables; import java.io.File; import java.io.IOException; -import java.io.Writer; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -41,7 +40,6 @@ import java.util.Set; class MultiProjectHtmlReporter extends HtmlReporter { private static final String INDEX_NAME = "index.html"; //$NON-NLS-1$ private final File mDir; - private List<String> mRoots; MultiProjectHtmlReporter(Main client, File dir) throws IOException { super(client, new File(dir, INDEX_NAME)); @@ -128,25 +126,27 @@ class MultiProjectHtmlReporter extends HtmlReporter { reporter.setStripPrefix(relative); reporter.write(projectErrorCount, projectWarningCount, issues); - projects.add(new ProjectEntry(project, fileName, projectErrorCount, - projectWarningCount, relative)); + projects.add(new ProjectEntry(fileName, projectErrorCount, projectWarningCount, + relative)); } // Write overview index? - if (projects.size() > 1) { - writeOverview(errorCount, warningCount, projects); - } + writeOverview(errorCount, warningCount, projects); + Closeables.closeQuietly(mWriter); + + File index = new File(mDir, INDEX_NAME); + System.out.println(); + System.out.println(String.format("Wrote overview index to %1$s", index)); } private void writeOverview(int errorCount, int warningCount, List<ProjectEntry> projects) throws IOException { - Writer writer = mWriter; - writer.write( + mWriter.write( "<html>\n" + //$NON-NLS-1$ "<head>\n" + //$NON-NLS-1$ "<title>" + mTitle + "</title>\n"); //$NON-NLS-1$//$NON-NLS-2$ writeStyleSheet(); - writer.write( + mWriter.write( "</head>\n" + //$NON-NLS-1$ "<body>\n" + //$NON-NLS-1$ "<h1>" + //$NON-NLS-1$ @@ -158,12 +158,18 @@ class MultiProjectHtmlReporter extends HtmlReporter { // Sort project list in decreasing order of errors, warnings and names Collections.sort(projects); - writer.write(String.format("Check performed at %1$s.", + mWriter.write(String.format("Check performed at %1$s.", new Date().toString())); - writer.write("<br/>"); //$NON-NLS-1$ - writer.write(String.format("%1$d errors and %2$d warnings found:\n", + mWriter.write("<br/>"); //$NON-NLS-1$ + mWriter.write(String.format("%1$d errors and %2$d warnings found:\n", errorCount, warningCount)); - writer.write("<br/><br/>"); //$NON-NLS-1$ + + mWriter.write("<br/><br/>"); //$NON-NLS-1$ + + if (errorCount == 0 && warningCount == 0) { + mWriter.write("Congratulations!"); + return; + } String errorUrl = null; String warningUrl = null; @@ -172,59 +178,50 @@ class MultiProjectHtmlReporter extends HtmlReporter { warningUrl = addLocalResources(HtmlReporter.getWarningIconUrl()); } - writer.write("<table class=\"overview\">\n"); //$NON-NLS-1$ - writer.write("<tr><th>"); //$NON-NLS-1$ - writer.write("Project"); - writer.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$ + mWriter.write("<table class=\"overview\">\n"); //$NON-NLS-1$ + mWriter.write("<tr><th>"); //$NON-NLS-1$ + mWriter.write("Project"); + mWriter.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$ if (errorUrl != null) { mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$ mWriter.write(errorUrl); mWriter.write("\" />\n"); //$NON-NLS-1$ } - writer.write("Errors"); - writer.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$ + mWriter.write("Errors"); + mWriter.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$ if (warningUrl != null) { mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$ mWriter.write(warningUrl); mWriter.write("\" />\n"); //$NON-NLS-1$ } - writer.write("Warnings"); - writer.write("</th></tr>\n"); //$NON-NLS-1$ + mWriter.write("Warnings"); + mWriter.write("</th></tr>\n"); //$NON-NLS-1$ for (ProjectEntry entry : projects) { - writer.write("<tr><td>"); //$NON-NLS-1$ - writer.write("<a href=\""); - writer.write(entry.fileName); // TODO: Escape? - writer.write("\">"); //$NON-NLS-1$ - writer.write(entry.path); - writer.write("</a></td><td class=\"countColumn\">"); //$NON-NLS-1$ - writer.write(Integer.toString(entry.errorCount)); - writer.write("</td><td class=\"countColumn\">"); //$NON-NLS-1$ - writer.write(Integer.toString(entry.warningCount)); - writer.write("</td></tr>\n"); //$NON-NLS-1$ + mWriter.write("<tr><td>"); //$NON-NLS-1$ + mWriter.write("<a href=\""); + mWriter.write(entry.fileName); // TODO: Escape? + mWriter.write("\">"); //$NON-NLS-1$ + mWriter.write(entry.path); + mWriter.write("</a></td><td class=\"countColumn\">"); //$NON-NLS-1$ + mWriter.write(Integer.toString(entry.errorCount)); + mWriter.write("</td><td class=\"countColumn\">"); //$NON-NLS-1$ + mWriter.write(Integer.toString(entry.warningCount)); + mWriter.write("</td></tr>\n"); //$NON-NLS-1$ } - writer.write("</table>\n"); //$NON-NLS-1$ - - Closeables.closeQuietly(writer); - - File index = new File(mDir, INDEX_NAME); - System.out.println(); - System.out.println(String.format("Wrote overview index to %1$s", index)); + mWriter.write("</table>\n"); //$NON-NLS-1$ } private static class ProjectEntry implements Comparable<ProjectEntry> { - public Project project; public int errorCount; public int warningCount; public String fileName; public String path; - public ProjectEntry(Project project, String fileName, int errorCount, int warningCount, - String path) { - this.project = project; + public ProjectEntry(String fileName, int errorCount, int warningCount, String path) { this.fileName = fileName; this.errorCount = errorCount; this.warningCount = warningCount; |