Skip to content

Commit 99a4ee9

Browse files
committed
added reporting utility
1 parent a3d4d01 commit 99a4ee9

File tree

4 files changed

+57
-19
lines changed

4 files changed

+57
-19
lines changed

CHECKS.md

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

build.hxml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
-cp resources
2-
-cmd neko run -s checkstyle -r xml -p resources/static-analysis.xml
3-
-x StaticAnalysis
4-
5-
-cmd rm StaticAnalysis.n
6-
--next
7-
82
-cp checkstyle
93
-lib hxparse:3.0.0
104
-lib haxeparser
@@ -17,6 +11,14 @@
1711
-main checkstyle.Main
1812
-neko run.n
1913

14+
--next
15+
16+
-cmd neko run -s checkstyle -r xml -p resources/static-analysis.xml
17+
18+
-main Report
19+
-neko report.n
20+
-cmd neko report
21+
2022
--next
2123
-cp test
2224
-main TestMain

report.n

32 KB
Binary file not shown.

resources/StaticAnalysis.hx renamed to resources/report.hx

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
11
package ;
22

3+
import haxe.CallStack;
4+
import hxargs.Args;
35
import sys.io.FileOutput;
46
import sys.io.File;
57

6-
class StaticAnalysis {
8+
class Report {
79

810
var _staticAnalysisXML:Xml;
911
var _reportFile:FileOutput;
1012

13+
var _path:String;
14+
15+
function run(args:Array<String>) {
16+
var files:Array<String> = [];
17+
var configPath:String = null;
18+
19+
var argHandler = Args.generate([
20+
@doc("xml path") ["-p", "--path"] => function(loc:String) _path = loc,
21+
_ => function(arg:String) throw "Unknown command: " + arg
22+
]);
23+
24+
if (args.length > 0) {
25+
argHandler.parse(args);
26+
}
27+
28+
generateReport();
29+
}
30+
1131
public function new() {
12-
_staticAnalysisXML = Xml.parse(File.getContent("./resources/static-analysis.xml"));
32+
_path = "./resources/static-analysis.xml";
33+
}
34+
35+
function generateReport() {
36+
_staticAnalysisXML = Xml.parse(File.getContent(_path));
1337
_reportFile = File.write("CHECKS.md", false);
1438
_reportFile.writeString("###Report of default checks on CheckStyle library itself\n\n");
1539
var errors = 0;
@@ -46,7 +70,28 @@ class StaticAnalysis {
4670
_reportFile.writeString("`Total Issues: " + total + " (Errors: " + errors + " Warnings: " + warnings + " Infos: " + infos + ")`");
4771
}
4872

49-
static function main() {
50-
new StaticAnalysis();
73+
@SuppressWarnings('checkstyle:Dynamic')
74+
public static function main() {
75+
var args;
76+
var cwd;
77+
var oldCwd = null;
78+
79+
try {
80+
args = Sys.args();
81+
cwd = Sys.getCwd();
82+
if (Sys.getEnv("HAXELIB_RUN") != null) {
83+
cwd = args.pop();
84+
oldCwd = Sys.getCwd();
85+
}
86+
if (oldCwd != null) Sys.setCwd(cwd);
87+
88+
var main = new Report();
89+
main.run(args);
90+
}
91+
catch(e:Dynamic) {
92+
trace(e);
93+
trace(CallStack.toString(CallStack.exceptionStack()));
94+
}
95+
if (oldCwd != null) Sys.setCwd(oldCwd);
5196
}
5297
}

0 commit comments

Comments
 (0)