#1337 False positive "Avoid throwing raw exception types" when exception is not thrown

This commit is contained in:
Andreas Dangel
2015-04-18 18:21:11 +02:00
parent 1910a6844c
commit fdb54ecc0e
3 changed files with 15 additions and 1 deletions

View File

@ -125,7 +125,7 @@ Exception, or Error, use a subclassed exception or error instead.
<property name="xpath">
<value>
<![CDATA[
//AllocationExpression
//ThrowStatement//AllocationExpression
/ClassOrInterfaceType[
(@Image='Throwable' and count(//ImportDeclaration/Name[ends-with(@Image,'Throwable')]) = 0)
or

View File

@ -40,4 +40,17 @@ public class PmdTest {
}
]]></code>
</test-code>
<test-code>
<description>#1337: False positive "Avoid throwing raw exception types" when exception is not thrown</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class PmdTest {
private Throwable cause;
public void setUp() {
cause = new Throwable();
}
}
]]></code>
</test-code>
</test-data>

View File

@ -16,6 +16,7 @@
* [#1332](https://sourceforge.net/p/pmd/bugs/1332/): False Positive: UnusedPrivateMethod
* [#1333](https://sourceforge.net/p/pmd/bugs/1333/): Error while processing Java file with Lambda expressions
* [#1337](https://sourceforge.net/p/pmd/bugs/1337/): False positive "Avoid throwing raw exception types" when exception is not thrown
* [#1338](https://sourceforge.net/p/pmd/bugs/1338/): The pmd-java8 POM bears the wrong parent module version
**API Changes:**