11package ;
22
3+ import haxe .CallStack ;
4+ import hxargs .Args ;
35import sys .io .FileOutput ;
46import 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