diff --git a/src/main/java/com/cflint/JSONOutput.java b/src/main/java/com/cflint/JSONOutput.java index 97d629674..43e2e6a2d 100644 --- a/src/main/java/com/cflint/JSONOutput.java +++ b/src/main/java/com/cflint/JSONOutput.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; +import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -74,6 +75,15 @@ public void output(final BugList bugList, final Writer writer, CFLintStats stats } } + jg.writeStartObject(); + jg.writeNumberField("totalfiles", stats.getFileCount()); + jg.writeEndObject(); + + jg.writeStartObject(); + jg.writeFieldName("totalsize"); + jg.writeNumber(stats.getTotalSize()); + jg.writeEndObject(); + for (final String code : counts.bugTypes()) { jg.writeStartObject(); jg.writeStringField("code", code); diff --git a/src/main/java/com/cflint/TextOutput.java b/src/main/java/com/cflint/TextOutput.java index fc15791c3..0e9fa2e3c 100644 --- a/src/main/java/com/cflint/TextOutput.java +++ b/src/main/java/com/cflint/TextOutput.java @@ -31,6 +31,9 @@ public void output(final BugList bugList, final Writer sb, CFLintStats stats) th } } + sb.append(newLine).append(newLine).append("Total files:" + stats.getFileCount()); + sb.append(newLine).append("Total size " + stats.getTotalSize()); + sb.append(newLine).append(newLine).append("Issue counts:" + counts.noBugTypes()); for (final String code : counts.bugTypes()) { diff --git a/src/test/java/com/cflint/TestJSONOutput.java b/src/test/java/com/cflint/TestJSONOutput.java index c5c8791ef..380d2808e 100644 --- a/src/test/java/com/cflint/TestJSONOutput.java +++ b/src/test/java/com/cflint/TestJSONOutput.java @@ -30,7 +30,7 @@ public void testOutput() throws IOException { bugList.add(bugInfo); CFLintStats stats = new CFLintStats(123456L,1,new BigInteger("545454")); outputer.output(bugList, writer, stats); - String expectedText = "[{\"severity\":\"\",\"id\":\"PARSE_ERROR\",\"message\":\"PARSE_ERROR\",\"category\":\"CFLINT\",\"abbrev\":\"PE\",\"locations\":[{\"file\":\"c:\\\\temp\\\\test.cfc\",\"fileName\":\"test.cfc\",\"function\":\"testf\",\"column\":1,\"line\":1,\"message\":\"\",\"variable\":\"\",\"expression\":\"\"}]}]"; + String expectedText = "[{\"severity\":\"\",\"id\":\"PARSE_ERROR\",\"message\":\"PARSE_ERROR\",\"category\":\"CFLINT\",\"abbrev\":\"PE\",\"locations\":[{\"file\":\"c:\\\\temp\\\\test.cfc\",\"fileName\":\"test.cfc\",\"function\":\"testf\",\"column\":1,\"line\":1,\"message\":\"\",\"variable\":\"\",\"expression\":\"\"}]},{\"totalfiles\":1},{\"totalsize\":545454}]"; // assertEquals(JSONValue.parse(expectedText),JSONValue.parse(writer.toString())); assertEquals(expectedText,writer.toString()); } @@ -43,7 +43,7 @@ public void testStats() throws IOException { counts.add("PARSE_ERROR", null); CFLintStats stats = new CFLintStats(123456L,1,new BigInteger("545454"),counts); outputer.output(bugList, writer, stats); - String expectedText = "[{\"severity\":\"\",\"id\":\"PARSE_ERROR\",\"message\":\"PARSE_ERROR\",\"category\":\"CFLINT\",\"abbrev\":\"PE\",\"locations\":[{\"file\":\"c:\\\\temp\\\\test.cfc\",\"fileName\":\"test.cfc\",\"function\":\"testf\",\"column\":1,\"line\":1,\"message\":\"\",\"variable\":\"\",\"expression\":\"\"}]},{\"code\":\"PARSE_ERROR\",\"count\":1}]"; + String expectedText = "[{\"severity\":\"\",\"id\":\"PARSE_ERROR\",\"message\":\"PARSE_ERROR\",\"category\":\"CFLINT\",\"abbrev\":\"PE\",\"locations\":[{\"file\":\"c:\\\\temp\\\\test.cfc\",\"fileName\":\"test.cfc\",\"function\":\"testf\",\"column\":1,\"line\":1,\"message\":\"\",\"variable\":\"\",\"expression\":\"\"}]},{\"totalfiles\":1},{\"totalsize\":545454},{\"code\":\"PARSE_ERROR\",\"count\":1}]"; assertEquals(expectedText,writer.toString()); } @@ -55,7 +55,7 @@ public void testStatsWithSeverity() throws IOException { counts.add("PARSE_ERROR", "ERROR"); CFLintStats stats = new CFLintStats(123456L,1,new BigInteger("545454"),counts); outputer.output(bugList, writer, stats); - String expectedText = "[{\"severity\":\"ERROR\",\"id\":\"PARSE_ERROR\",\"message\":\"PARSE_ERROR\",\"category\":\"CFLINT\",\"abbrev\":\"PE\",\"locations\":[{\"file\":\"c:\\\\temp\\\\test.cfc\",\"fileName\":\"test.cfc\",\"function\":\"testf\",\"column\":1,\"line\":1,\"message\":\"\",\"variable\":\"\",\"expression\":\"\"}]},{\"code\":\"PARSE_ERROR\",\"count\":1},{\"severity\":\"ERROR\",\"count\":1}]"; + String expectedText = "[{\"severity\":\"ERROR\",\"id\":\"PARSE_ERROR\",\"message\":\"PARSE_ERROR\",\"category\":\"CFLINT\",\"abbrev\":\"PE\",\"locations\":[{\"file\":\"c:\\\\temp\\\\test.cfc\",\"fileName\":\"test.cfc\",\"function\":\"testf\",\"column\":1,\"line\":1,\"message\":\"\",\"variable\":\"\",\"expression\":\"\"}]},{\"totalfiles\":1},{\"totalsize\":545454},{\"code\":\"PARSE_ERROR\",\"count\":1},{\"severity\":\"ERROR\",\"count\":1}]"; assertEquals(expectedText,writer.toString()); } diff --git a/src/test/resources/com/cflint/integration/output.expected.json b/src/test/resources/com/cflint/integration/output.expected.json index 6d5789c47..af3726989 100644 --- a/src/test/resources/com/cflint/integration/output.expected.json +++ b/src/test/resources/com/cflint/integration/output.expected.json @@ -62,6 +62,10 @@ "variable" : "getStringFromStruct", "expression" : "public string function getStringFromStruct(interestingVar) {\n return interestingVar;\n\n }" } ] +}, { + "totalfiles" : 3 +}, { + "totalsize" : 18 }, { "code" : "FUNCTION_HINT_MISSING", "count" : 3 diff --git a/src/test/resources/com/cflint/integration/output.rulegroup.expected.json b/src/test/resources/com/cflint/integration/output.rulegroup.expected.json index b991ccdb6..a416e3150 100644 --- a/src/test/resources/com/cflint/integration/output.rulegroup.expected.json +++ b/src/test/resources/com/cflint/integration/output.rulegroup.expected.json @@ -14,6 +14,10 @@ "variable" : "", "expression" : "component {\n public string function getStringFromStruct(interestingVar) {\n return interestingVar;\n\n }\n}" } ] +}, { + "totalfiles" : 3 +}, { + "totalsize" : 18 }, { "code" : "COMPONENT_INVALID_NAME", "count" : 1 diff --git a/src/test/resources/com/cflint/integration/output_194.expected.json b/src/test/resources/com/cflint/integration/output_194.expected.json index b991ccdb6..a416e3150 100644 --- a/src/test/resources/com/cflint/integration/output_194.expected.json +++ b/src/test/resources/com/cflint/integration/output_194.expected.json @@ -14,6 +14,10 @@ "variable" : "", "expression" : "component {\n public string function getStringFromStruct(interestingVar) {\n return interestingVar;\n\n }\n}" } ] +}, { + "totalfiles" : 3 +}, { + "totalsize" : 18 }, { "code" : "COMPONENT_INVALID_NAME", "count" : 1