#1418 RedundantFieldInitializer false positive with large long value

This commit is contained in:
Andreas Dangel
2015-10-03 17:36:07 +02:00
parent 3bf91a84d6
commit 73fe285b1a
3 changed files with 18 additions and 6 deletions

View File

@ -100,7 +100,7 @@ public class RedundantFieldInitializerRule extends AbstractJavaRule {
value = (int) literal.getImage().charAt(1);
}
if (value.intValue() == 0) {
if (value.longValue() == 0) {
addViolation(data, variableDeclarator);
}
}

View File

@ -1292,4 +1292,14 @@ public class Bar {
}
</code>
</test-code>
<test-code>
<description>#1418 RedundantFieldInitializer false positive with large long value</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class SomeClass {
private long someNumber = 0x100000000000L;
}
]]></code>
</test-code>
</test-data>

View File

@ -22,14 +22,16 @@
**Bugfixes:**
* java-controversial/DefaultPackage:
* [#1410](https://sourceforge.net/p/pmd/bugs/1410/): DefaultPackage triggers on field annotated with @VisibleForTesting
* [#1410](https://sourceforge.net/p/pmd/bugs/1410/): DefaultPackage triggers on field annotated with @VisibleForTesting
* java-design/CloseResource:
* [#1387](https://sourceforge.net/p/pmd/bugs/1387/): CloseResource has false positive for ResultSet
* [#1387](https://sourceforge.net/p/pmd/bugs/1387/): CloseResource has false positive for ResultSet
* java-optimizations/RedundantFieldInitializer
* [#1418](https://sourceforge.net/p/pmd/bugs/1418/): RedundantFieldInitializer false positive with large long value
* java-strings/InsufficientStringBufferDeclaration:
* [#1409](https://sourceforge.net/p/pmd/bugs/1409/): NullPointerException in InsufficientStringBufferRule
* [#1413](https://sourceforge.net/p/pmd/bugs/1413/): False positive StringBuffer constructor with ?: int value
* [#1409](https://sourceforge.net/p/pmd/bugs/1409/): NullPointerException in InsufficientStringBufferRule
* [#1413](https://sourceforge.net/p/pmd/bugs/1413/): False positive StringBuffer constructor with ?: int value
* java-unnecessary/UselessParentheses:
* [#1407](https://sourceforge.net/p/pmd/bugs/1407/): UselessParentheses "&" and "+" operator precedence
* [#1407](https://sourceforge.net/p/pmd/bugs/1407/): UselessParentheses "&" and "+" operator precedence
**API Changes:**