File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed
src/checkstyle/checks/design Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 33
44language : haxe
55haxe :
6- - 3.4.0
6+ - 3.4.2
77 - development
88install :
99 - haxelib install haxeparser 3.3.0
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ class UnnecessaryConstructorCheck extends Check {
1414 var root : TokenTree = checker .getTokenTree ();
1515 var classes : Array <TokenTree > = root .filter ([Kwd (KwdClass )], ALL );
1616 for (cls in classes ) {
17+ if (extendsBaseClass (cls )) {
18+ continue ;
19+ }
1720 var acceptableTokens : Array <TokenTree > = cls .filter ([
1821 Kwd (KwdFunction ),
1922 Kwd (KwdVar )
@@ -40,4 +43,14 @@ class UnnecessaryConstructorCheck extends Check {
4043 }
4144 }
4245 }
43- }
46+
47+ function extendsBaseClass (cls : TokenTree ): Bool {
48+ var clsName : TokenTree = cls .getFirstChild ();
49+ for (child in clsName .children ) {
50+ if (child .is (Kwd (KwdExtends ))) {
51+ return true ;
52+ }
53+ }
54+ return false ;
55+ }
56+ }
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ class UnnecessaryConstructorCheckTest extends CheckTestCase<UnnecessaryConstruct
3131 public function testStaticOnlyWithNew () {
3232 assertNoMsg (new UnnecessaryConstructorCheck (), TEST_STATIC_ONLY_WITH_NEW );
3333 }
34+
35+ public function testChildClass () {
36+ assertNoMsg (new UnnecessaryConstructorCheck (), TEST_CHILD_CLASS );
37+ }
3438}
3539
3640@:enum
@@ -104,4 +108,15 @@ abstract UnnecessaryConstructorCheckTests(String) to String {
104108 VAR1 = new String();
105109 }
106110 }" ;
107- }
111+
112+ var TEST_CHILD_CLASS = "
113+ class Test extends Base
114+ {
115+ public static var VAR1:String = 'test';
116+
117+ public function new()
118+ {
119+ super(VAR1);
120+ }
121+ }" ;
122+ }
You can’t perform that action at this time.
0 commit comments