Skip to content

Commit 6ad092b

Browse files
committed
refactored reporting
1 parent c41ebc0 commit 6ad092b

File tree

5 files changed

+13
-23
lines changed

5 files changed

+13
-23
lines changed

CHECKS.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

build.hxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
--each
1010

1111
-main checkstyle.Main
12+
-D checkstyle
1213
-neko run.n
1314

1415
--next

checkstyle/Main.hx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Main {
3030
var main = new Main();
3131
main.run(args);
3232

33-
if (REPORT) {
33+
if (REPORT && REPORT_TYPE == "xml") {
3434
var reporter = new Report();
3535
reporter.generateReport(PATH);
3636
}
@@ -47,7 +47,7 @@ class Main {
4747
var checker:Checker;
4848

4949
static var REPORT:Bool = false;
50-
static var REPORT_TYPE:String = "default";
50+
static var REPORT_TYPE:String = "xml";
5151
static var PATH:String = "check-style-report.xml";
5252
static var STYLE:String = "";
5353

@@ -66,7 +66,6 @@ class Main {
6666
@doc("Set reporter path") ["-p", "--path"] => function(loc:String) PATH = loc,
6767
@doc("Set reporter style (XSLT)") ["-x", "--xslt"] => function(x:String) STYLE = x,
6868
@doc("Set reporter") ["-r", "--reporter"] => function(reporterName:String) REPORT_TYPE = reporterName,
69-
@doc("List all reporters") ["--list-reporters"] => function() listReporters(),
7069
@doc("Set config file") ["-c", "--config"] => function(cpath:String) configPath = cpath,
7170
@doc("List all checks") ["--list-checks"] => function() listChecks(),
7271
@doc("Generate build time report") ["-report"] => function() REPORT = true,
@@ -117,12 +116,6 @@ class Main {
117116
for (check in info.checks()) Sys.println('${check.name}: ${check.description}');
118117
}
119118

120-
static function listReporters() {
121-
Sys.println("default - Default reporter");
122-
Sys.println("xml - Checkstyle-like XML reporter");
123-
Sys.exit(0);
124-
}
125-
126119
static function createReporter():IReporter {
127120
return switch(REPORT_TYPE) {
128121
case "xml": new XMLReporter(PATH, STYLE);

checkstyle/Report.hx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package checkstyle;
22

3+
#if checkstyle
34
import sys.io.FileOutput;
45
import sys.io.File;
6+
#end
57

68
class Report {
79

@@ -13,8 +15,12 @@ class Report {
1315
@SuppressWarnings('checkstyle:LineLength')
1416
public function generateReport(path:String) {
1517
staticAnalysisXML = Xml.parse(File.getContent(path));
18+
19+
#if checkstyle
1620
reportFile = File.write("CHECKS.md", false);
1721
reportFile.writeString("###Report of default checks on CheckStyle library itself\n\n");
22+
#end
23+
1824
var errors = 0;
1925
var warnings = 0;
2026
var infos = 0;
@@ -30,22 +36,21 @@ class Report {
3036
case "error":
3137
errors++;
3238
Sys.println("\t\033[91mError: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "\033[0m");
33-
reportFile.writeString("`Error: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "`\n\n");
39+
#if checkstyle reportFile.writeString("`Error: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "`\n\n"); #end
3440
case "warning":
3541
warnings++;
3642
Sys.println("\t\033[95mWarning: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "\033[0m");
37-
reportFile.writeString("`Warning: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "`\n\n");
43+
#if checkstyle reportFile.writeString("`Warning: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "`\n\n"); #end
3844
case "info":
3945
infos++;
4046
Sys.println("\t\033[94mInfo: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "\033[0m");
41-
reportFile.writeString("`Info: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "`\n\n");
47+
#if checkstyle reportFile.writeString("`Info: LINE - " + errorNode.get("line") + ": " + StringTools.htmlUnescape(errorNode.get("message")) + "`\n\n"); #end
4248
}
4349
total++;
4450
}
4551
}
4652

4753
Sys.println("\033[1m\nTotal Issues: " + total + " (\033[0m\033[91mErrors: " + errors + "\033[0m, \033[95mWarnings: " + warnings + "\033[0m, \033[94mInfos: " + infos + ")\n" + "\033[0m");
48-
49-
reportFile.writeString("`Total Issues: " + total + " (Errors: " + errors + " Warnings: " + warnings + " Infos: " + infos + ")`");
54+
#if checkstyle reportFile.writeString("`Total Issues: " + total + " (Errors: " + errors + " Warnings: " + warnings + " Infos: " + infos + ")`"); #end
5055
}
5156
}

run.n

-363 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)