Skip to content

Commit

Permalink
display error/warning count in EpubCheck result // fixes #655
Browse files Browse the repository at this point in the history
  • Loading branch information
tofi86 committed Jul 17, 2017
1 parent 8ad72ec commit b7babed
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 9 deletions.
18 changes: 17 additions & 1 deletion src/main/java/com/adobe/epubcheck/api/MasterReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public abstract class MasterReport implements Report
{
public static Set<MessageId> allReportedMessageIds = new HashSet<MessageId>();
int errorCount, warningCount, fatalErrorCount, usageCount = 0;
int errorCount, warningCount, fatalErrorCount, usageCount, infoCount = 0;
int reportingLevel = ReportingLevel.Info;
private String ePubName;
private MessageDictionary dictionary = new MessageDictionary(null, this);
Expand Down Expand Up @@ -72,6 +72,10 @@ else if (severity.equals(Severity.USAGE))
{
usageCount++;
}
else if (severity.equals(Severity.INFO))
{
infoCount++;
}
this.message(message, location, args);
}
reportMessageId(id);
Expand Down Expand Up @@ -138,6 +142,18 @@ public int getFatalErrorCount()
return fatalErrorCount;
}

@Override
public int getInfoCount()
{
return infoCount;
}

@Override
public int getUsageCount()
{
return usageCount;
}

@Override
public void close()
{
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/adobe/epubcheck/api/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public interface Report

public int getFatalErrorCount();

public int getInfoCount();

public int getUsageCount();

/**
* Called to create a report after the checks have been made
*/
Expand Down
41 changes: 35 additions & 6 deletions src/main/java/com/adobe/epubcheck/tool/EpubChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,13 @@ else if (report.getWarningCount() > 0 && report.getFatalErrorCount() == 0 && rep

public int run(String[] args)
{
Report report = null;
int returnValue = 1;
try
{
if (processArguments(args))
{
Report report = createReport();
report = createReport();
report.initialize();
if (listChecks)
{
Expand All @@ -288,12 +289,40 @@ public int run(String[] args)
returnValue = 1;
} finally
{
outWriter.println(Messages.get("epubcheck_completed"));
outWriter.setQuiet(false);
printEpubCheckCompleted(report);
}
return returnValue;
}

private void printEpubCheckCompleted(Report report)
{
if(report != null) {
StringBuilder messageCount = new StringBuilder();
if(reportingLevel <= ReportingLevel.Fatal) {
messageCount.append(Messages.get("messages") + ": ");
messageCount.append(String.format(Messages.get("counter_fatal"), report.getFatalErrorCount()));
}
if(reportingLevel <= ReportingLevel.Error) {
messageCount.append(" / " + String.format(Messages.get("counter_error"), report.getErrorCount()));
}
if(reportingLevel <= ReportingLevel.Warning) {
messageCount.append(" / " + String.format(Messages.get("counter_warn"), report.getWarningCount()));
}
if(reportingLevel <= ReportingLevel.Info) {
messageCount.append(" / " + String.format(Messages.get("counter_info"), report.getInfoCount()));
}
if(reportingLevel <= ReportingLevel.Usage) {
messageCount.append(" / " + String.format(Messages.get("counter_usage"), report.getUsageCount()));
}
if(messageCount.length() > 0) {
messageCount.append("\n");
outWriter.println(messageCount);
}
}
outWriter.println(Messages.get("epubcheck_completed"));
outWriter.setQuiet(false);
}

private void dumpMessageDictionary(Report report)
throws IOException
{
Expand Down Expand Up @@ -384,12 +413,13 @@ else if (xmpOutput)

public int processEpubFile(String[] args)
{
Report report = null;
int returnValue = 1;
try
{
if (processArguments(args))
{
Report report = createReport();
report = createReport();
report.initialize();
if (listChecks)
{
Expand All @@ -412,8 +442,7 @@ public int processEpubFile(String[] args)
returnValue = 1;
} finally
{
outWriter.println(Messages.get("epubcheck_completed"));
outWriter.setQuiet(false);
printEpubCheckCompleted(report);
}
return returnValue;
}
Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/com/adobe/epubcheck/util/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ opv_version_test=*** Candidate for msg deletion *** Tests are performed only for
mode_version_not_supported=The checker doesn't validate type %1$s and version %2$s.
no_errors__or_warnings=No errors or warnings detected.
there_were_errors=\nCheck finished with errors\n
there_were_warnings=\nCheck finished with warnings\n
there_were_errors=\nCheck finished with errors
there_were_warnings=\nCheck finished with warnings
messages=Messages
counter_fatal=%1$d fatal
counter_error=%1$d errors
counter_warn=%1$d warnings
counter_info=%1$d info
counter_usage=%1$d usage
error_processing_unexpanded_epub=\nThis check cannot process expanded epubs\n
deleting_archive=\nEpub creation cancelled due to detected errors.\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.
ERROR(CSS-001): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style.css(56,5): The 'direction' property must not be included in an EPUB Style Sheet.

Check finished with errors
Messages: 0 fatal / 5 errors

epubcheck completed
Completed command_line test('severity_error')
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Start command_line test('severity_fatal')
No errors or warnings detected.
Messages: 0 fatal

epubcheck completed
Completed command_line test('severity_fatal')
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Check finished with errors
Messages: 0 fatal / 6 errors / 6 warnings / 0 info / 63 usage

epubcheck completed
Completed command_line test('severity_overrideBadId')
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Check finished with errors
Messages: 0 fatal / 7 errors / 6 warnings / 0 info / 63 usage

epubcheck completed
Completed command_line test('severity_overrideBadMessage')
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Check finished with errors
Messages: 0 fatal / 6 errors / 6 warnings / 0 info / 63 usage

epubcheck completed
Completed command_line test('severity_overrideBadSeverity')
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Check finished with errors
Messages: 0 fatal / 6 errors / 6 warnings / 0 info / 63 usage

epubcheck completed
Completed command_line test('severity_overrideMissingFile')
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Check finished with errors
Messages: 0 fatal / 7 errors / 6 warnings / 0 info / 60 usage

epubcheck completed
Completed command_line test('severity_overrideOk')
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused
USAGE(CSS-024): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/unused.css(66,3): CSS class Selector is not used.

Check finished with errors
Messages: 0 fatal / 5 errors / 6 warnings / 0 info / 63 usage

epubcheck completed
Completed command_line test('severity_usage')
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ WARNING(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/cssS
WARNING(CSS-017): ./com/adobe/epubcheck/test/command_line/severity.epub/OPS/style_tag_css.xhtml(17,13): CSS selector specifies absolute position.

Check finished with errors
Messages: 0 fatal / 5 errors / 6 warnings

epubcheck completed
Completed command_line test('severity_warning')

0 comments on commit b7babed

Please sign in to comment.