Skip to content

Commit

Permalink
supplemental: Enforced new naming convention on executablestatementcount
Browse files Browse the repository at this point in the history
  • Loading branch information
MANISH-K-07 authored and nrmancuso committed Mar 26, 2024
1 parent 164a83d commit e70b8b5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected String getCheckName() {
@Test
public void testDefaultConfig() throws Exception {
final String filePath =
getPath("SuppressionXpathRegressionExecutableStatementCountDefault.java");
getPath("InputXpathExecutableStatementCountDefault.java");
final File fileToProcess = new File(filePath);

final DefaultConfiguration moduleConfig =
Expand All @@ -54,14 +54,14 @@ public void testDefaultConfig() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountDefault']]"
+ "@text='InputXpathExecutableStatementCountDefault']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='ElseIfLadder']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountDefault']]"
+ "@text='InputXpathExecutableStatementCountDefault']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='ElseIfLadder']]"
+ "/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountDefault']]"
+ "@text='InputXpathExecutableStatementCountDefault']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='ElseIfLadder']]"
+ "/MODIFIERS/LITERAL_PUBLIC"
);
Expand All @@ -73,7 +73,7 @@ public void testDefaultConfig() throws Exception {
@Test
public void testCustomMax() throws Exception {
final String filePath =
getPath("SuppressionXpathRegressionExecutableStatementCountCustomMax.java");
getPath("InputXpathExecutableStatementCountCustomMax.java");
final File fileToProcess = new File(filePath);

final DefaultConfiguration moduleConfig =
Expand All @@ -88,18 +88,18 @@ public void testCustomMax() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountCustomMax']]"
+ "@text='InputXpathExecutableStatementCountCustomMax']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountCustomMax']]",
+ "@text='InputXpathExecutableStatementCountCustomMax']]",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountCustomMax']]"
+ "@text='InputXpathExecutableStatementCountCustomMax']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountCustomMax']]"
+ "@text='InputXpathExecutableStatementCountCustomMax']]"
+ "/MODIFIERS",
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountCustomMax']]"
+ "@text='InputXpathExecutableStatementCountCustomMax']]"
+ "/OBJBLOCK/CTOR_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionExecutableStatementCountCustomMax']]"
+ "@text='InputXpathExecutableStatementCountCustomMax']]"
+ "/MODIFIERS/LITERAL_PUBLIC"
);

Expand All @@ -109,7 +109,7 @@ public void testCustomMax() throws Exception {
@Test
public void testLambdas() throws Exception {
final String filePath =
getPath("SuppressionXpathRegressionExecutableStatementCountLambdas.java");
getPath("InputXpathExecutableStatementCountLambdas.java");
final File fileToProcess = new File(filePath);

final DefaultConfiguration moduleConfig =
Expand All @@ -124,7 +124,7 @@ public void testLambdas() throws Exception {

final List<String> expectedXpathQueries = List.of(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionExecutableStatementCountLambdas']]"
+ "[@text='InputXpathExecutableStatementCountLambdas']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='c']]/ASSIGN/LAMBDA"
);

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

public class SuppressionXpathRegressionExecutableStatementCountCustomMax {
public SuppressionXpathRegressionExecutableStatementCountCustomMax() // warn
public class InputXpathExecutableStatementCountCustomMax {
public InputXpathExecutableStatementCountCustomMax() // warn
{
int i = 1;
if (System.currentTimeMillis() == 0) {
Expand All @@ -10,5 +10,5 @@ public SuppressionXpathRegressionExecutableStatementCountCustomMax() // warn
}
}
/** Empty constructor */
public SuppressionXpathRegressionExecutableStatementCountCustomMax(int i) {}
public InputXpathExecutableStatementCountCustomMax(int i) {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkstyle.suppressionxpathfilter.executablestatementcount;

public class SuppressionXpathRegressionExecutableStatementCountDefault {
public class InputXpathExecutableStatementCountDefault {
public void ElseIfLadder() { // warn
if (System.currentTimeMillis() == 0) {
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.function.Consumer;
import java.util.function.Function;

public class SuppressionXpathRegressionExecutableStatementCountLambdas {
public class InputXpathExecutableStatementCountLambdas {
Consumer c = (s) -> { // warn
String str = s.toString();
str = str + "!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class XpathRegressionTest extends AbstractModuleTestSupport {
private static final Set<String> INTERNAL_MODULES = getInternalModules();

// Checks whose files need to be renamed to new pattern "InputXpath{Check}Xxx.java"
// till checkstyle issue
// until https://github.com/checkstyle/checkstyle/issues/14715
private static final Set<String> RENAME_INPUT_XPATH = Set.of(
"AbbreviationAsWordInName",
"AbstractClassName",
Expand Down Expand Up @@ -153,7 +153,6 @@ public class XpathRegressionTest extends AbstractModuleTestSupport {
"EmptyStatement",
"EqualsAvoidNull",
"EqualsHashCode",
"ExecutableStatementCount",
"ExplicitInitialization",
"FallThrough",
"FinalClass",
Expand Down

0 comments on commit e70b8b5

Please sign in to comment.