Skip to content

Commit

Permalink
Issue checkstyle#6356: Xpath: change implementation of the @text attr…
Browse files Browse the repository at this point in the history
…ibute
  • Loading branch information
timurt committed Mar 8, 2019
1 parent a2a13dc commit d5e7897
Show file tree
Hide file tree
Showing 51 changed files with 1,346 additions and 539 deletions.
12 changes: 6 additions & 6 deletions config/suppressions-xpath.xml
Expand Up @@ -7,16 +7,16 @@
<suppressions>
<!-- Tone down the checking for test code -->
<suppress-xpath checks="NPathComplexity"
query="/CLASS_DEF[@text='XdocsPagesTest']
//METHOD_DEF[@text='validateCheckSection'
or @text='getModulePropertyExpectedValue']"/>
query="/CLASS_DEF[./IDENT[@text='XdocsPagesTest']]
//METHOD_DEF[./IDENT[@text='validateCheckSection'
or @text='getModulePropertyExpectedValue']]"/>

<suppress-xpath checks="CyclomaticComplexity"
query="/CLASS_DEF[@text='XdocsPagesTest']//METHOD_DEF"/>
query="/CLASS_DEF[./IDENT[@text='XdocsPagesTest']]//METHOD_DEF"/>

<!-- Suppressions from PMD configuration-->
<!-- JavadocMethodCheck, JavadocStyleCheck, JavadocUtil.getJavadocTags() - deprecated -->
<suppress-xpath checks="CyclomaticComplexity"
query="/CLASS_DEF[@text='JavadocMethodCheck' or @text='JavadocStyleCheck'
or @text='CustomImportOrderCheck']//METHOD_DEF"/>
query="/CLASS_DEF[./IDENT[@text='JavadocMethodCheck'
or @text='JavadocStyleCheck' or @text='CustomImportOrderCheck']]//METHOD_DEF"/>
</suppressions>
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -3086,6 +3086,7 @@
<version>${pitest.plugin.version}</version>
<configuration>
<mutators>
<mutator>REMOVE_CONDITIONALS</mutator>
<mutator>CONDITIONALS_BOUNDARY</mutator>
<mutator>CONSTRUCTOR_CALLS</mutator>
<mutator>FALSE_RETURNS</mutator>
Expand Down
Expand Up @@ -51,12 +51,15 @@ public void testOne() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionClassMemberImpliedModifierOne']"
+ "/OBJBLOCK/INTERFACE_DEF[@text='Foo']",
"/CLASS_DEF[@text='SuppressionXpathRegressionClassMemberImpliedModifierOne']"
+ "/OBJBLOCK/INTERFACE_DEF[@text='Foo']/MODIFIERS",
"/CLASS_DEF[@text='SuppressionXpathRegressionClassMemberImpliedModifierOne']"
+ "/OBJBLOCK/INTERFACE_DEF[@text='Foo']/MODIFIERS/LITERAL_PUBLIC"
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionClassMemberImpliedModifierOne']]"
+ "/OBJBLOCK/INTERFACE_DEF[./IDENT[@text='Foo']]",
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionClassMemberImpliedModifierOne']]"
+ "/OBJBLOCK/INTERFACE_DEF[./IDENT[@text='Foo']]/MODIFIERS",
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionClassMemberImpliedModifierOne']]"
+ "/OBJBLOCK/INTERFACE_DEF[./IDENT[@text='Foo']]/MODIFIERS/LITERAL_PUBLIC"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand All @@ -77,12 +80,12 @@ public void testTwo() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionClassMemberImpliedModifierTwo']"
+ "/OBJBLOCK/ENUM_DEF[@text='Count']",
"/CLASS_DEF[@text='SuppressionXpathRegressionClassMemberImpliedModifierTwo']"
+ "/OBJBLOCK/ENUM_DEF[@text='Count']/MODIFIERS",
"/CLASS_DEF[@text='SuppressionXpathRegressionClassMemberImpliedModifierTwo']"
+ "/OBJBLOCK/ENUM_DEF[@text='Count']/MODIFIERS/LITERAL_PUBLIC"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionClassMemberImpliedModifierTwo']]"
+ "/OBJBLOCK/ENUM_DEF[./IDENT[@text='Count']]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionClassMemberImpliedModifierTwo']]"
+ "/OBJBLOCK/ENUM_DEF[./IDENT[@text='Count']]/MODIFIERS",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionClassMemberImpliedModifierTwo']]"
+ "/OBJBLOCK/ENUM_DEF[./IDENT[@text='Count']]/MODIFIERS/LITERAL_PUBLIC"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -53,12 +53,12 @@ public void testOne() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionCyclomaticOne']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']",
"/CLASS_DEF[@text='SuppressionXpathRegressionCyclomaticOne']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']/MODIFIERS",
"/CLASS_DEF[@text='SuppressionXpathRegressionCyclomaticOne']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']/MODIFIERS/LITERAL_PUBLIC"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionCyclomaticOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionCyclomaticOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/MODIFIERS",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionCyclomaticOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/MODIFIERS/LITERAL_PUBLIC"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand All @@ -80,12 +80,12 @@ public void testTwo() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionCyclomaticTwo']/OBJBLOCK"
+ "/METHOD_DEF[@text='foo2']",
"/CLASS_DEF[@text='SuppressionXpathRegressionCyclomaticTwo']/OBJBLOCK"
+ "/METHOD_DEF[@text='foo2']/MODIFIERS",
"/CLASS_DEF[@text='SuppressionXpathRegressionCyclomaticTwo']/OBJBLOCK"
+ "/METHOD_DEF[@text='foo2']/MODIFIERS/LITERAL_PUBLIC"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionCyclomaticTwo']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='foo2']]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionCyclomaticTwo']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='foo2']]/MODIFIERS",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionCyclomaticTwo']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='foo2']]/MODIFIERS/LITERAL_PUBLIC"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -51,12 +51,12 @@ public void testOne() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionDeclarationOne']"
+ "/OBJBLOCK/VARIABLE_DEF[@text='name']",
"/CLASS_DEF[@text='SuppressionXpathRegressionDeclarationOne']"
+ "/OBJBLOCK/VARIABLE_DEF[@text='name']/MODIFIERS",
"/CLASS_DEF[@text='SuppressionXpathRegressionDeclarationOne']"
+ "/OBJBLOCK/VARIABLE_DEF[@text='name']/MODIFIERS/LITERAL_PUBLIC"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDeclarationOne']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='name']]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDeclarationOne']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='name']]/MODIFIERS",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDeclarationOne']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='name']]/MODIFIERS/LITERAL_PUBLIC"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand All @@ -77,12 +77,12 @@ public void testTwo() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionDeclarationTwo']"
+ "/OBJBLOCK/VARIABLE_DEF[@text='MAX']",
"/CLASS_DEF[@text='SuppressionXpathRegressionDeclarationTwo']"
+ "/OBJBLOCK/VARIABLE_DEF[@text='MAX']/MODIFIERS",
"/CLASS_DEF[@text='SuppressionXpathRegressionDeclarationTwo']"
+ "/OBJBLOCK/VARIABLE_DEF[@text='MAX']/MODIFIERS/LITERAL_PUBLIC"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDeclarationTwo']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='MAX']]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDeclarationTwo']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='MAX']]/MODIFIERS",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDeclarationTwo']]"
+ "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='MAX']]/MODIFIERS/LITERAL_PUBLIC"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -52,10 +52,10 @@ public void testOne() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionDefaultComesLastOne']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']/SLIST/LITERAL_SWITCH/CASE_GROUP",
"/CLASS_DEF[@text='SuppressionXpathRegressionDefaultComesLastOne']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']/SLIST/LITERAL_SWITCH/CASE_GROUP"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDefaultComesLastOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP[1]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDefaultComesLastOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP"
+ "/LITERAL_DEFAULT"
);

Expand All @@ -78,8 +78,9 @@ public void testTwo() throws Exception {
};

final List<String> expectedXpathQueries = Collections.singletonList(
"/CLASS_DEF[@text='SuppressionXpathRegressionDefaultComesLastTwo']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']/SLIST/LITERAL_SWITCH/CASE_GROUP/LITERAL_DEFAULT"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionDefaultComesLastTwo']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP"
+ "/LITERAL_DEFAULT"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -52,10 +52,10 @@ public void testPreceded() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForInitializerPadPreceded']"
+ "/OBJBLOCK/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/FOR_INIT",
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForInitializerPadPreceded']"
+ "/OBJBLOCK/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/SEMI"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionEmptyForInitializerPadPreceded']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/FOR_INIT",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionEmptyForInitializerPadPreceded']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/SEMI[1]"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand All @@ -77,10 +77,12 @@ public void testNotPreceded() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForInitializerPadNotPreceded']"
+ "/OBJBLOCK/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/FOR_INIT",
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForInitializerPadNotPreceded']"
+ "/OBJBLOCK/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/SEMI"
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionEmptyForInitializerPadNotPreceded']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/FOR_INIT",
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionEmptyForInitializerPadNotPreceded']]"
+ "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/SEMI[1]"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -52,10 +52,12 @@ public void testFollowed() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForIteratorPadFollowed']/OBJBLOCK"
+ "/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/FOR_ITERATOR",
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForIteratorPadFollowed']/OBJBLOCK"
+ "/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/RPAREN"
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionEmptyForIteratorPadFollowed']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/FOR_ITERATOR",
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionEmptyForIteratorPadFollowed']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/RPAREN"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand All @@ -77,10 +79,12 @@ public void testNotFollowed() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForIteratorPadNotFollowed']/OBJBLOCK"
+ "/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/FOR_ITERATOR",
"/CLASS_DEF[@text='SuppressionXpathRegressionEmptyForIteratorPadNotFollowed']/OBJBLOCK"
+ "/METHOD_DEF[@text='method']/SLIST/LITERAL_FOR/RPAREN"
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionEmptyForIteratorPadNotFollowed']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/FOR_ITERATOR",
"/CLASS_DEF[./IDENT["
+ "@text='SuppressionXpathRegressionEmptyForIteratorPadNotFollowed']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_FOR/RPAREN"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -51,8 +51,8 @@ public void testOne() throws Exception {
};

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

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand All @@ -73,8 +73,8 @@ public void testTwo() throws Exception {
};

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

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand Down
Expand Up @@ -51,10 +51,10 @@ public void testOne() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionExplicitOne']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']/SLIST/LITERAL_SWITCH/CASE_GROUP",
"/CLASS_DEF[@text='SuppressionXpathRegressionExplicitOne']/OBJBLOCK"
+ "/METHOD_DEF[@text='test']/SLIST/LITERAL_SWITCH/CASE_GROUP/LITERAL_CASE"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionExplicitOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP[3]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionExplicitOne']]/OBJBLOCK"
+ "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP/LITERAL_CASE"
);

runVerifications(moduleConfig, fileToProcess, expectedViolation,
Expand All @@ -76,11 +76,13 @@ public void testTwo() throws Exception {
};

final List<String> expectedXpathQueries = Arrays.asList(
"/CLASS_DEF[@text='SuppressionXpathRegressionExplicitTwo']/OBJBLOCK"
+ "/METHOD_DEF[@text='methodFallThruCustomWords']/SLIST/LITERAL_WHILE/SLIST"
+ "/LITERAL_SWITCH/CASE_GROUP",
"/CLASS_DEF[@text='SuppressionXpathRegressionExplicitTwo']/OBJBLOCK"
+ "/METHOD_DEF[@text='methodFallThruCustomWords']/SLIST/LITERAL_WHILE/SLIST"
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionExplicitTwo']]/OBJBLOCK"
+ "/METHOD_DEF["
+ "./IDENT[@text='methodFallThruCustomWords']]/SLIST/LITERAL_WHILE/SLIST"
+ "/LITERAL_SWITCH/CASE_GROUP[2]",
"/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionExplicitTwo']]/OBJBLOCK"
+ "/METHOD_DEF["
+ "./IDENT[@text='methodFallThruCustomWords']]/SLIST/LITERAL_WHILE/SLIST"
+ "/LITERAL_SWITCH/CASE_GROUP/LITERAL_DEFAULT"
);

Expand Down

0 comments on commit d5e7897

Please sign in to comment.