Skip to content

Commit

Permalink
Issue #14715: Enforced new naming convention on visibilitymodifier in…
Browse files Browse the repository at this point in the history
… IT area
  • Loading branch information
MANISH-K-07 authored and romani committed Mar 26, 2024
1 parent cd1afd9 commit 194a6f7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected String getCheckName() {
@Test
public void testDefaultModifier() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionVisibilityModifierDefault.java"));
new File(getPath("InputXpathVisibilityModifierDefault.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(VisibilityModifierCheck.class);
Expand All @@ -53,7 +53,7 @@ public void testDefaultModifier() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionVisibilityModifierDefault']]"
+ "@text='InputXpathVisibilityModifierDefault']]"
+ "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='field']"
);

Expand All @@ -63,7 +63,7 @@ public void testDefaultModifier() throws Exception {
@Test
public void testAnnotation() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionVisibilityModifierAnnotation.java"));
new File(getPath("InputXpathVisibilityModifierAnnotation.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(VisibilityModifierCheck.class);
Expand All @@ -76,7 +76,7 @@ public void testAnnotation() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionVisibilityModifierAnnotation']]"
+ "@text='InputXpathVisibilityModifierAnnotation']]"
+ "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='annotatedString']"
);

Expand All @@ -86,7 +86,7 @@ public void testAnnotation() throws Exception {
@Test
public void testAnonymousClass() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionVisibilityModifierAnonymous.java"));
new File(getPath("InputXpathVisibilityModifierAnonymous.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(VisibilityModifierCheck.class);
Expand All @@ -97,7 +97,7 @@ public void testAnonymousClass() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionVisibilityModifierAnonymous']]"
+ "@text='InputXpathVisibilityModifierAnonymous']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='runnable']]"
+ "/ASSIGN/EXPR/LITERAL_NEW[./IDENT[@text='Runnable']]"
+ "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='field1']"
Expand All @@ -109,7 +109,7 @@ public void testAnonymousClass() throws Exception {
@Test
public void testInnerClass() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionVisibilityModifierInner.java"));
new File(getPath("InputXpathVisibilityModifierInner.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(VisibilityModifierCheck.class);
Expand All @@ -120,7 +120,7 @@ public void testInnerClass() throws Exception {

final List<String> expectedXpathQueries = Collections.singletonList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionVisibilityModifierInner']]"
+ "@text='InputXpathVisibilityModifierInner']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='InnerClass']]/OBJBLOCK/"
+ "VARIABLE_DEF/IDENT[@text='field2']"
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkstyle.suppressionxpathfilter.visibilitymodifier;

public class SuppressionXpathRegressionVisibilityModifierAnnotation {
public class InputXpathVisibilityModifierAnnotation {
@java.lang.Deprecated
String annotatedString; // warn

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkstyle.suppressionxpathfilter.visibilitymodifier;

public class SuppressionXpathRegressionVisibilityModifierAnonymous {
public class InputXpathVisibilityModifierAnonymous {
private Runnable runnable = new Runnable() {

public String field1; // warn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkstyle.suppressionxpathfilter.visibilitymodifier;

public class SuppressionXpathRegressionVisibilityModifierDefault {
public class InputXpathVisibilityModifierDefault {
private int myPrivateField; // ok, private class member is allowed

int field; // warn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkstyle.suppressionxpathfilter.visibilitymodifier;

public class SuppressionXpathRegressionVisibilityModifierInner {
public class InputXpathVisibilityModifierInner {
class InnerClass {
private int field1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ public class XpathRegressionTest extends AbstractModuleTestSupport {
"UnusedLocalVariable",
"UpperEll",
"VariableDeclarationUsageDistance",
"VisibilityModifier",
"WhitespaceAfter",
"WhitespaceAround",
"IllegalIdentifierName",
Expand Down

0 comments on commit 194a6f7

Please sign in to comment.