Skip to content

Commit

Permalink
Fix deprecated attribute usage
Browse files Browse the repository at this point in the history
  • Loading branch information
oowekyala committed Dec 16, 2019
1 parent 76d33ea commit 50560e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ In JUnit 5, one of the following annotations should be used for tests: @Test, @R
<value>
<![CDATA[
//ClassOrInterfaceDeclaration[
matches(@Image, $testClassPattern)
matches(@SimpleName, $testClassPattern)
or ExtendsList/ClassOrInterfaceType[pmd-java:typeIs('junit.framework.TestCase')]]
/ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration[MethodDeclaration[@Public=true() and starts-with(@Name, 'test')]]
Expand Down
24 changes: 12 additions & 12 deletions pmd-java/src/main/resources/category/java/codestyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ by {% rule java/codestyle/ClassNamingConventions %}.
<![CDATA[
//ClassOrInterfaceDeclaration
[@Abstract='true' and @Interface='false']
[not (starts-with(@Image,'Abstract'))]
[not (starts-with(@SimpleName,'Abstract'))]
|
//ClassOrInterfaceDeclaration
[@Abstract='false']
[$strict='true']
[starts-with(@Image, 'Abstract')]
[starts-with(@SimpleName, 'Abstract')]
]]>
</value>
</property>
Expand Down Expand Up @@ -161,7 +161,7 @@ by the more general rule {% rule java/codestyle/FormalParameterNamingConventions
<value>
<![CDATA[
//MethodDeclaration/MethodDeclarator/FormalParameters/FormalParameter/VariableDeclaratorId[
pmd:matches(@Image,'^in[A-Z].*','^out[A-Z].*','^in$','^out$')
pmd:matches(@VariableName,'^in[A-Z].*','^out[A-Z].*','^in$','^out$')
]
]]>
</value>
Expand Down Expand Up @@ -1092,7 +1092,7 @@ The Local Home interface of a Session EJB should be suffixed by 'LocalHome'.
and
not
(
ends-with(@Image,'LocalHome')
ends-with(@SimpleName,'LocalHome')
)
]
]]>
Expand Down Expand Up @@ -1130,7 +1130,7 @@ The Local Interface of a Session EJB should be suffixed by 'Local'.
and
not
(
ends-with(@Image,'Local')
ends-with(@SimpleName,'Local')
)
]
]]>
Expand Down Expand Up @@ -1261,7 +1261,7 @@ The EJB Specification states that any MessageDrivenBean or SessionBean should be
and
not
(
ends-with(@Image,'Bean')
ends-with(@SimpleName,'Bean')
)
]
]]>
Expand Down Expand Up @@ -1541,11 +1541,11 @@ Remote Interface of a Session EJB should not have a suffix.
)
and
(
ends-with(@Image,'Session')
ends-with(@SimpleName,'Session')
or
ends-with(@Image,'EJB')
ends-with(@SimpleName,'EJB')
or
ends-with(@Image,'Bean')
ends-with(@SimpleName,'Bean')
)
]
]]>
Expand Down Expand Up @@ -1588,7 +1588,7 @@ A Remote Home interface type of a Session EJB should be suffixed by 'Home'.
and
not
(
ends-with(@Image,'Home')
ends-with(@SimpleName,'Home')
)
]
]]>
Expand Down Expand Up @@ -1619,7 +1619,7 @@ Short Classnames with fewer than e.g. five characters are not recommended.
<property name="xpath">
<value>
<![CDATA[
//ClassOrInterfaceDeclaration[string-length(@Image) < $minimum]
//ClassOrInterfaceDeclaration[string-length(@SimpleName) < $minimum]
]]>
</value>
</property>
Expand Down Expand Up @@ -2096,7 +2096,7 @@ public class Foo {
[PrimarySuffix[@Arguments='false' and @ArrayDereference = 'false']]
[not(PrimarySuffix/MemberSelector)]
[ancestor::ClassOrInterfaceBodyDeclaration[1][@AnonymousInnerClass='false']]
/PrimaryPrefix/Name[@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image]
/PrimaryPrefix/Name[@Image = ancestor::ClassOrInterfaceDeclaration[1]/@SimpleName]
]]>
</value>
</property>
Expand Down
16 changes: 8 additions & 8 deletions pmd-java/src/main/resources/category/java/errorprone.xml
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ public String bar(String string) {
@Name='onStart'
]
/Block[not(
(BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image]))]
(BlockStatement[1]/Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name]))]
[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
pmd-java:typeIs('android.app.Activity') or
pmd-java:typeIs('android.app.Application') or
Expand Down Expand Up @@ -750,7 +750,7 @@ Super should be called at the end of the method
@Name='onTerminate'
]
/Block/BlockStatement[last()]
[not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/MethodDeclarator/@Image])]
[not(Statement/StatementExpression/PrimaryExpression[./PrimaryPrefix[@SuperModifier='true']]/PrimarySuffix[@Image= ancestor::MethodDeclaration/@Name])]
[ancestor::ClassOrInterfaceDeclaration[ExtendsList/ClassOrInterfaceType[
pmd-java:typeIs('android.app.Activity') or
pmd-java:typeIs('android.app.Application') or
Expand Down Expand Up @@ -939,7 +939,7 @@ Note: This is only possible with Java 1.5 or higher.
[
@Name = 'clone'
and @Arity = 0
and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@Image)
and not (ResultType//ClassOrInterfaceType/@Image = ancestor::ClassOrInterfaceDeclaration[1]/@SimpleName)
]
]]>
</value>
Expand Down Expand Up @@ -2452,10 +2452,10 @@ See the property `annotations`.
[(./ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration/MethodDeclaration
[@Public=true()]
[./ResultType/Type/ReferenceType/ClassOrInterfaceType
[@Image = //ClassOrInterfaceDeclaration[@Nested=false()]/@Image]
[@Image = //ClassOrInterfaceDeclaration[@Nested=false()]/@SimpleName]
]
) or (
./ExtendsList/ClassOrInterfaceType[@Image = //ClassOrInterfaceDeclaration[@Nested=false()]/@Image]
./ExtendsList/ClassOrInterfaceType[@Image = //ClassOrInterfaceDeclaration[@Nested=false()]/@SimpleName]
)]
)
]
Expand Down Expand Up @@ -2650,7 +2650,7 @@ Object clone() should be implemented with super.clone().
[count(./Block//*[
(self::AllocationExpression) and
(./ClassOrInterfaceType/@Image = ancestor::
ClassOrInterfaceDeclaration[1]/@Image)
ClassOrInterfaceDeclaration[1]/@SimpleName)
])> 0
]
]]>
Expand Down Expand Up @@ -2696,8 +2696,8 @@ with the restriction that the logger needs to be passed into the constructor.
or (@Static = false() and .//VariableDeclaratorId[@Image != $loggerName])
(: check logger argument type matches class or enum name :)
or .//ArgumentList//ClassOrInterfaceType[@Image != ancestor::ClassOrInterfaceDeclaration/@Image]
or .//ArgumentList//ClassOrInterfaceType[@Image != ancestor::EnumDeclaration/@Image]
or .//ArgumentList//ClassOrInterfaceType[@Image != ancestor::ClassOrInterfaceDeclaration/@SimpleName]
or .//ArgumentList//ClassOrInterfaceType[@Image != ancestor::EnumDeclaration/@SimpleName]
]
[not(
(: special case - final logger initialized inside constructor :)
Expand Down
2 changes: 1 addition & 1 deletion pmd-java/src/main/resources/category/java/performance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ ArrayList is a much better Collection implementation than Vector if thread-safe
<property name="xpath">
<value>
<![CDATA[
//CompilationUnit[count(ImportDeclaration) = 0 or count(ImportDeclaration/Name[@Image='java.util.Vector']) > 0]
//CompilationUnit[count(ImportDeclaration) = 0 or count(ImportDeclaration[@ImportedName='java.util.Vector']) > 0]
//AllocationExpression/ClassOrInterfaceType
[@Image='Vector' or @Image='java.util.Vector']
]]>
Expand Down

0 comments on commit 50560e0

Please sign in to comment.