Affects PMD Version:
6.22.0
Rule:
DontCallThreadRun
Description:
DontCallThreadRun can't detect the case that call run()
in foo.bar.run()
. This rule is implemented through xpath search: This rule is implemented through xpath search:
//StatementExpression/PrimaryExpression
[
PrimaryPrefix
[
./Name[ends-with(@Image, '.run') or @Image = 'run']
and substring-before(Name/@Image, '.') =//VariableDeclarator/VariableDeclaratorId/@Image
[../../../Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]]
or (./AllocationExpression/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]
and ../PrimarySuffix[@Image = 'run'])
]
]
AST analyse result of the code sample:
<PrimaryPrefix FindBoundary='false' Image='' SingleLine='true' SuperModifier='false' ThisModifier='false'>
<Name FindBoundary='false' Image='client.blink.run' SingleLine='true' />
</PrimaryPrefix>
<PrimarySuffix ArgumentCount='0' Arguments='true' ArrayDereference='false' FindBoundary='false' Image='' SingleLine='true'>
<Arguments ArgumentCount='0' FindBoundary='false' Image='' SingleLine='true' Size='0' />
</PrimarySuffix>
Possible error when detecting whether the type of client.blink
is java.lang.Thread
Code Sample demonstrating the issue:
Expected outcome:
false-negative
Running PMD through:
CLI
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4