#1246 False positive from MissingBreakInSwitch

This commit is contained in:
Andreas Dangel
2014-08-24 11:42:00 +02:00
parent eaa58d7f5f
commit b41e6ff682
3 changed files with 7 additions and 2 deletions

View File

@ -929,8 +929,9 @@ may indicate problematic behaviour. Empty cases are ignored as these indicate an
[(count(.//BreakStatement)
+ count(BlockStatement/Statement/ReturnStatement)
+ count(BlockStatement/Statement/ThrowStatement)
+ count(BlockStatement/Statement/IfStatement[@Else='true' and Statement[2][ReturnStatement|ThrowStatement]]/Statement[1][ReturnStatement|ThrowStatement])
+ count(SwitchLabel[name(following-sibling::node()) = 'SwitchLabel'])
+ count(SwitchLabel[count(following-sibling::node()) = 0 or count(child::node()) = 0])
+ count(SwitchLabel[count(following-sibling::node()) = 0])
< count (SwitchLabel))]
]]>
</value>

View File

@ -16,6 +16,7 @@
* [#1241](https://sourceforge.net/p/pmd/bugs/1241/): False+ AvoidProtectedMethodInFinalClassNotExtending
* [#1243](https://sourceforge.net/p/pmd/bugs/1243/): Useless Parentheses False Positive
* [#1245](https://sourceforge.net/p/pmd/bugs/1245/): False Positive for Law of Demeter
* [#1246](https://sourceforge.net/p/pmd/bugs/1246/): False positive from MissingBreakInSwitch
* [#1247](https://sourceforge.net/p/pmd/bugs/1247/): Not able to recognize JDK 8 Static Method References
**Feature Requests and Improvements:**

View File

@ -140,7 +140,10 @@ public class Foo {
else
return null;
case x3:
return new Object();
if (condition)
return new Object();
else
return null;
default:
return null;
}