Skip to content

Commit

Permalink
Issue checkstyle#13345: enable test for AvoidNoArgumentSuperConstruct…
Browse files Browse the repository at this point in the history
…orCallCheck
  • Loading branch information
Lmh-java authored and nrmancuso committed Mar 10, 2024
1 parent b518572 commit 3870875
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

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

import org.junit.jupiter.api.Disabled;
import static com.puppycrawl.tools.checkstyle.checks.coding.AvoidNoArgumentSuperConstructorCallCheck.MSG_CTOR;

import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;

@Disabled("until https://github.com/checkstyle/checkstyle/issues/13345")
public class AvoidNoArgumentSuperConstructorCallCheckExamplesTest
extends AbstractExamplesModuleTestSupport {
@Override
Expand All @@ -35,9 +35,9 @@ protected String getPackageLocation() {
@Test
public void testExample1() throws Exception {
final String[] expected = {

"17:5: " + getCheckMessage(MSG_CTOR),
};

verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
verifyWithInlineConfigParser(getPath("Example1.java"), expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="AvoidNoArgumentSuperConstructorCall"/>
</module>
</module>
*/
package com.puppycrawl.tools.checkstyle.checks.coding.avoidnoargumentsuperconstructorcall;

// xdoc section -- start
class SuperClass {
public SuperClass() {}
public SuperClass(int arg) {}
}
class Example1 extends SuperClass {
Example1() {
super(); // violation
}

Example1(int arg) {
super(arg); // ok, explicit constructor invocation with argument
}

Example1(long arg) {
// ok, no explicit constructor invocation
}
}
// xdoc section -- end

This file was deleted.

24 changes: 14 additions & 10 deletions src/xdocs/checks/coding/avoidnoargumentsuperconstructorcall.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,22 @@
Example of violations
</p>
<source>
class MyClass extends SomeOtherClass {
MyClass() {
super(); // violation
}
class SuperClass {
public SuperClass() {}
public SuperClass(int arg) {}
}
class Example1 extends SuperClass {
Example1() {
super(); // violation
}

MyClass(int arg) {
super(arg); // OK, call with argument have to be explicit
}
Example1(int arg) {
super(arg); // ok, explicit constructor invocation with argument
}

MyClass(long arg) {
// OK, call is implicit
}
Example1(long arg) {
// ok, no explicit constructor invocation
}
}
</source>
</subsection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example1-code">
Example of violations
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.txt"/>
value="resources/com/puppycrawl/tools/checkstyle/checks/coding/avoidnoargumentsuperconstructorcall/Example1.java"/>
<param name="type" value="code"/>
</macro>
</subsection>
Expand Down

0 comments on commit 3870875

Please sign in to comment.