forked from phoedos/pmd
Fixed patch 2075906 - Add toString() to the rule UnnecessaryWrapperObjectCreation
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6591 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
parent
9893f33977
commit
10f5aa8d69
@ -3,6 +3,7 @@
|
||||
Fixed bug 1481051 - false + UnusedNullCheckInEquals (and other false positives too)
|
||||
Fixed bug 1943204 - Ant task: <ruleset> path should be relative to Ant basedir
|
||||
Fixed bug 2139720 - Exception in PMD Rule Designer for inline comments in source
|
||||
Fixed patch 2075906 - Add toString() to the rule UnnecessaryWrapperObjectCreation
|
||||
Fixed ClassCastException on generic method in BeanMembersShouldSerialize
|
||||
Fixed ClassCastException in symbol table code
|
||||
|
||||
|
@ -40,4 +40,17 @@ public class Bar {
|
||||
]]></code>
|
||||
<source-type>java 1.5</source-type>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description><![CDATA[
|
||||
Patch 2075906: Add toString() to the rule UnnecessaryWrapperObjectCreation
|
||||
]]></description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Bar {
|
||||
void foo(boolean value) {
|
||||
String b = Boolean.valueOf(value).toString();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
@ -307,6 +307,9 @@ public int convert(String s) {
|
||||
i2 = Integer.valueOf(i).intValue(); // this wastes an object
|
||||
i2 = i; // this is better
|
||||
|
||||
String s3 = Integer.valueOf(i2).toString(); // this wastes an object
|
||||
s3 = Integer.toString(i2); // this is better
|
||||
|
||||
return i2;
|
||||
}
|
||||
]]>
|
||||
|
@ -25,6 +25,7 @@ public class UnnecessaryWrapperObjectCreation extends AbstractRule {
|
||||
});
|
||||
|
||||
private static final Set<String> suffixSet = CollectionUtil.asSet(new String[] {
|
||||
"toString",
|
||||
"byteValue",
|
||||
"shortValue",
|
||||
"intValue",
|
||||
|
Loading…
x
Reference in New Issue
Block a user