Skip to content

Commit

Permalink
For yegor256#982: Removed CallSuperInConstructor rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulodamaso committed Feb 7, 2019
1 parent 558b197 commit ef690f5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions qulice-pmd/src/main/resources/com/qulice/pmd/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="DefaultPackage"/>
<exclude name="LinguisticNaming"/>
<exclude name="CallSuperInConstructor"/>
</rule>
<rule ref="category/java/design.xml">
<exclude name="LoosePackageCoupling"/>
Expand Down
22 changes: 22 additions & 0 deletions qulice-pmd/src/test/java/com/qulice/pmd/PmdValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import org.hamcrest.Matchers;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains;
import org.hamcrest.object.HasToString;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -613,4 +615,24 @@ public void allowsDuplicateLiteralsInAnnotations() throws Exception {
)
).validate();
}

/**
* PmdValidator does not require constructor with super().
*
* @throws Exception If something wrong happens inside.
*/
@Test
public void dontRequireSuperInConstructor()
throws Exception {
final String file = "DontCallSuperInConstructor.java";
new PmdAssert(
file,
new IsEqual<>(true),
new IsNot<>(
new StringContains(
"CallSuperInConstructor"
)
)
).validate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package foo;

public final class DontCallSuperInConstructor {

private final int number;
private final int other;

public DontCallSuperInConstructor(final int parameter) {
this(parameter, parameter * 2);
}

public DontCallSuperInConstructor(final int parameter, final int other) {
this.number = parameter;
this.another = other;
}

public int num() {
return number + another;
}
}

0 comments on commit ef690f5

Please sign in to comment.