Skip to content

@VariableName in XPath rule replacement (due to deprecation and removal from PMD 7) #4860

Answered by adangel
pnatashap asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, here is the updated rule for various PMD versions:

PMD 6.55.0 - XPath 1.0:

//Name[@Image = //FieldDeclaration[@Static='true']/VariableDeclarator/VariableDeclaratorId/@Name]

Note: Replaced @VariableName with VariableDeclarator/VariableDeclaratorId/@Name

PMD 6.55.0 - XPath 2.0:

//Name[@Image = //FieldDeclaration[@Static=true()]/VariableDeclarator/VariableDeclaratorId/@Name]

Note: The static attribute is now a real boolean value and not a string anymore.
Note 2: You also need to set <property name="version" value="2.0"/>.
Note 3: This is the prerequisite for update to PMD 7

PMD 7.0.0-rc4:

//VariableAccess[@Name = //FieldDeclaration[@Static=true()]/VariableDeclarator/VariableDeclaratorI…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@oowekyala
Comment options

Comment options

You must be logged in to vote
1 reply
@pnatashap
Comment options

Answer selected by pnatashap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants