Skip to content

Commit 3870875

Browse files
Lmh-javanrmancuso
authored andcommitted
Issue #13345: enable test for AvoidNoArgumentSuperConstructorCallCheck
1 parent b518572 commit 3870875

File tree

5 files changed

+48
-39
lines changed

5 files changed

+48
-39
lines changed

src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckExamplesTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
package com.puppycrawl.tools.checkstyle.checks.coding;
2121

22-
import org.junit.jupiter.api.Disabled;
22+
import static com.puppycrawl.tools.checkstyle.checks.coding.AvoidNoArgumentSuperConstructorCallCheck.MSG_CTOR;
23+
2324
import org.junit.jupiter.api.Test;
2425

2526
import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
2627

27-
@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
2828
public class AvoidNoArgumentSuperConstructorCallCheckExamplesTest
2929
extends AbstractExamplesModuleTestSupport {
3030
@Override
@@ -35,9 +35,9 @@ protected String getPackageLocation() {
3535
@Test
3636
public void testExample1() throws Exception {
3737
final String[] expected = {
38-
38+
"17:5: " + getCheckMessage(MSG_CTOR),
3939
};
4040

41-
verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
41+
verifyWithInlineConfigParser(getPath("Example1.java"), expected);
4242
}
4343
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*xml
2+
<module name="Checker">
3+
<module name="TreeWalker">
4+
<module name="AvoidNoArgumentSuperConstructorCall"/>
5+
</module>
6+
</module>
7+
*/
8+
package com.puppycrawl.tools.checkstyle.checks.coding.avoidnoargumentsuperconstructorcall;
9+
10+
// xdoc section -- start
11+
class SuperClass {
12+
public SuperClass() {}
13+
public SuperClass(int arg) {}
14+
}
15+
class Example1 extends SuperClass {
16+
Example1() {
17+
super(); // violation
18+
}
19+
20+
Example1(int arg) {
21+
super(arg); // ok, explicit constructor invocation with argument
22+
}
23+
24+
Example1(long arg) {
25+
// ok, no explicit constructor invocation
26+
}
27+
}
28+
// xdoc section -- end

src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.txt

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

src/xdocs/checks/coding/avoidnoargumentsuperconstructorcall.xml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,22 @@
3333
Example of violations
3434
</p>
3535
<source>
36-
class MyClass extends SomeOtherClass {
37-
MyClass() {
38-
super(); // violation
39-
}
36+
class SuperClass {
37+
public SuperClass() {}
38+
public SuperClass(int arg) {}
39+
}
40+
class Example1 extends SuperClass {
41+
Example1() {
42+
super(); // violation
43+
}
4044

41-
MyClass(int arg) {
42-
super(arg); // OK, call with argument have to be explicit
43-
}
45+
Example1(int arg) {
46+
super(arg); // ok, explicit constructor invocation with argument
47+
}
4448

45-
MyClass(long arg) {
46-
// OK, call is implicit
47-
}
49+
Example1(long arg) {
50+
// ok, no explicit constructor invocation
51+
}
4852
}
4953
</source>
5054
</subsection>

src/xdocs/checks/coding/avoidnoargumentsuperconstructorcall.xml.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
</p>
2525
<macro name="example">
2626
<param name="path"
27-
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.txt"/>
27+
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.java"/>
2828
<param name="type" value="config"/>
2929
</macro>
3030
<p id="Example1-code">
3131
Example of violations
3232
</p>
3333
<macro name="example">
3434
<param name="path"
35-
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.txt"/>
35+
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.java"/>
3636
<param name="type" value="code"/>
3737
</macro>
3838
</subsection>

0 commit comments

Comments
 (0)