Skip to content

Commit

Permalink
Issue checkstyle#13345: Enable examples tests for ClassMemberImpliedM…
Browse files Browse the repository at this point in the history
…odifierCheck
  • Loading branch information
AmitKumarDeoghoria authored and romani committed Nov 15, 2024
1 parent b89afb9 commit 2e23e27
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

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

import org.junit.jupiter.api.Disabled;
import static com.puppycrawl.tools.checkstyle.checks.modifier.ClassMemberImpliedModifierCheck.MSG_KEY;

import org.junit.jupiter.api.Test;

import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;

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

"16:3: " + getCheckMessage(MSG_KEY, "static"),
"23:3: " + getCheckMessage(MSG_KEY, "static"),
"29:3: " + getCheckMessage(MSG_KEY, "static"),
"34:5: " + getCheckMessage(MSG_KEY, "static"),
};

verifyWithInlineConfigParser(getPath("Example1.txt"), expected);
verifyWithInlineConfigParser(
getNonCompilablePath("Example1.java"), expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*xml
<module name="Checker">
<module name="TreeWalker">
<module name="ClassMemberImpliedModifier" />
</module>
</module>
*/
//non-compiled with javac: Compilable with Java17
package com.puppycrawl.tools.checkstyle.checks.modifier.classmemberimpliedmodifier;

// xdoc section -- start
public final class Example1 {
static interface Address1 {
}

interface Address2 { // violation, 'Implied modifier 'static' should be explicit'
}

static enum Age1 {
CHILD, ADULT
}

enum Age2 { // violation, 'Implied modifier 'static' should be explicit'
CHILD, ADULT
}

public static record GoodRecord() {}
// violation below, 'Implied modifier 'static' should be explicit'
public record BadRecord() {}

public static record OuterRecord() {
static record InnerRecord1(){}
// violation below, 'Implied modifier 'static' should be explicit'
record InnerRecord2(){}
}
}
// xdoc section -- end

This file was deleted.

20 changes: 11 additions & 9 deletions src/xdocs/checks/modifier/classmemberimpliedmodifier.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,29 @@ public final class Person {
Code:
</p>
<source>
public final class Person {
static interface Address1 { // valid
public final class Example1 {
static interface Address1 {
}

interface Address2 { // violation
interface Address2 { // violation, 'Implied modifier 'static' should be explicit'
}

static enum Age1 { // valid
static enum Age1 {
CHILD, ADULT
}

enum Age2 { // violation
enum Age2 { // violation, 'Implied modifier 'static' should be explicit'
CHILD, ADULT
}

public static record GoodRecord() {} // valid
public record BadRecord() {} // violation
public static record GoodRecord() {}
// violation below, 'Implied modifier 'static' should be explicit'
public record BadRecord() {}

public static record OuterRecord() {
static record InnerRecord1(){} // valid
record InnerRecord2(){} // violation
static record InnerRecord1(){}
// violation below, 'Implied modifier 'static' should be explicit'
record InnerRecord2(){}
}
}
</source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public final class Person {
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/modifier/classmemberimpliedmodifier/Example1.txt"/>
value="resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/modifier/classmemberimpliedmodifier/Example1.java"/>
<param name="type" value="config"/>
</macro>
<p id="Example1-code">
Code:
</p>
<macro name="example">
<param name="path"
value="resources/com/puppycrawl/tools/checkstyle/checks/modifier/classmemberimpliedmodifier/Example1.txt"/>
value="resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/modifier/classmemberimpliedmodifier/Example1.java"/>
<param name="type" value="code"/>
</macro>
</subsection>
Expand Down

0 comments on commit 2e23e27

Please sign in to comment.