Skip to content

Commit

Permalink
Issue #14715: Enforce new naming convention on methodtypeparameternam…
Browse files Browse the repository at this point in the history
…e in IT area
  • Loading branch information
Kexin2000 authored and rnveach committed Mar 29, 2024
1 parent d35128b commit e20f9e2
Show file tree
Hide file tree
Showing 5 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 test1() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodTypeParameterName1.java"));
new File(getPath("InputXpathMethodTypeParameterNameDefault.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(MethodTypeParameterNameCheck.class);
Expand All @@ -54,11 +54,11 @@ public void test1() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./"
+ "IDENT[@text='SuppressionXpathRegressionMethodTypeParameterName1']]"
+ "IDENT[@text='InputXpathMethodTypeParameterNameDefault']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/TYPE_PARAMETERS"
+ "/TYPE_PARAMETER[./IDENT[@text='TT']]", "/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionMethodTypeParameterName1']]"
+ "@text='InputXpathMethodTypeParameterNameDefault']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]"
+ "/TYPE_PARAMETERS/TYPE_PARAMETER/IDENT[@text='TT']"
);
Expand All @@ -69,7 +69,7 @@ public void test1() throws Exception {
@Test
public void test2() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodTypeParameterName2.java"));
new File(getPath("InputXpathMethodTypeParameterNameInner.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(MethodTypeParameterNameCheck.class);
Expand All @@ -82,12 +82,12 @@ public void test2() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionMethodTypeParameterName2']]"
+ "@text='InputXpathMethodTypeParameterNameInner']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Junk']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='foo']]/TYPE_PARAMETERS"
+ "/TYPE_PARAMETER[./IDENT[@text='fo_']]", "/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionMethodTypeParameterName2']]"
+ "'InputXpathMethodTypeParameterNameInner']]"
+ "/OBJBLOCK/CLASS_DEF[./IDENT[@text='Junk']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='foo']]/TYPE_PARAMETERS"
+ "/TYPE_PARAMETER/IDENT[@text='fo_']"
Expand All @@ -99,7 +99,7 @@ public void test2() throws Exception {
@Test
public void test3() throws Exception {
final File fileToProcess =
new File(getPath("SuppressionXpathRegressionMethodTypeParameterName3.java"));
new File(getPath("InputXpathMethodTypeParameterNameLowercase.java"));

final DefaultConfiguration moduleConfig =
createModuleConfig(MethodTypeParameterNameCheck.class);
Expand All @@ -112,11 +112,11 @@ public void test3() throws Exception {

final List<String> expectedXpathQueries = Arrays.asList(
"/COMPILATION_UNIT/CLASS_DEF[./IDENT"
+ "[@text='SuppressionXpathRegressionMethodTypeParameterName3']]"
+ "[@text='InputXpathMethodTypeParameterNameLowercase']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myMethod']]/TYPE_PARAMETERS"
+ "/TYPE_PARAMETER[./IDENT[@text='a_a']]", "/COMPILATION_UNIT"
+ "/CLASS_DEF[./IDENT[@text="
+ "'SuppressionXpathRegressionMethodTypeParameterName3']]"
+ "'InputXpathMethodTypeParameterNameLowercase']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myMethod']]"
+ "/TYPE_PARAMETERS/TYPE_PARAMETER/IDENT[@text='a_a']"
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.checkstyle.suppressionxpathfilter.methodtypeparametername;

public class SuppressionXpathRegressionMethodTypeParameterName1{
public class InputXpathMethodTypeParameterNameDefault {
public <TT> void foo() { } // warn
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.checkstyle.suppressionxpathfilter.methodtypeparametername;

public class SuppressionXpathRegressionMethodTypeParameterName2 <T>{
public class InputXpathMethodTypeParameterNameInner<T>{

static class Junk <T> {
<fo_ extends T> void foo() { // warn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

public class SuppressionXpathRegressionMethodTypeParameterName3<T> {
public class InputXpathMethodTypeParameterNameLowercase<T> {

<a_a> a_a myMethod(List<? super T> list) {return null;} // warn

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ public class XpathRegressionTest extends AbstractModuleTestSupport {
"MethodLength",
"MethodName",
"MethodParamPad",
"MethodTypeParameterName",
"MissingCtor",
"MissingJavadocMethod",
"MissingJavadocPackage",
Expand Down

0 comments on commit e20f9e2

Please sign in to comment.