Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pmd7 avoid unused assignments #424

Open
wants to merge 2 commits into
base: pmd7
Choose a base branch
from
Open

Conversation

stokpop
Copy link
Collaborator

@stokpop stokpop commented Nov 20, 2024

This is the last PMD7 rule to migrate, work in progress, need help :-)

Not ready to merge yet!

@stokpop
Copy link
Collaborator Author

stokpop commented Nov 20, 2024

Also tried something like this, to see if next usage is before the next assignment:

for $node in //Block//ExpressionStatement/AssignmentExpression
   return $node[
     let $nextAssignment := following::ExpressionStatement/AssignmentExpression/VariableAccess[$node//VariableAccess/@Name = @Name][1],
         $nextUse := following::ExpressionStatement//(MethodCall|UnaryExpression)/VariableAccess[$node//VariableAccess/@Name = @Name][1]
     return 
       let $nextAssignmentPos := $nextAssignment/../position(), $nextUsePos := $nextUse/../position() 
       return $nextAssignmentPos > $nextUsePos
   ]

@stokpop stokpop linked an issue Jan 28, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Finish migration of AvoidUnusedAssignments
1 participant