Fixed issue
This commit is contained in:
@ -54,7 +54,7 @@ public class UselessStringValueOfRule extends AbstractJavaRule {
|
||||
&& "+".equals(gp.getImage())) {
|
||||
boolean ok = false;
|
||||
if (gp.getChild(0) == parent) {
|
||||
ok = !isPrimitive(gp.getChild(1));
|
||||
return super.visit(node, data);
|
||||
} else {
|
||||
for (int i = 0; !ok && gp.getChild(i) != parent; i++) {
|
||||
ok = !isPrimitive(gp.getChild(i));
|
||||
|
@ -109,6 +109,27 @@ public class Test {
|
||||
private void print(String s) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#3492 False positive for UselessStringValueOf, when there is no initial String to append to</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Test {
|
||||
private short getPrefix(long id) {
|
||||
return 0;
|
||||
}
|
||||
private short getTimestamp(long id) {
|
||||
return 0;
|
||||
}
|
||||
private short getCounter(long id) {
|
||||
return 0;
|
||||
}
|
||||
public String toShortString(long id) {
|
||||
return String.valueOf(getPrefix(id)) + getTimestamp(id) + getCounter(id); // (12)
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Reference in New Issue
Block a user