forked from phoedos/pmd
Merge branch 'master' into 7.0.x
This commit is contained in:
2
.github/ISSUE_TEMPLATE/rule_violation.md
vendored
2
.github/ISSUE_TEMPLATE/rule_violation.md
vendored
@ -2,7 +2,7 @@
|
||||
name: Rule violation
|
||||
about: Let us know about a false positive/false negative
|
||||
title: ''
|
||||
labels: 'a:bug'
|
||||
labels: 'a:false-positive, a:false-negative'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
11
pmd-java/src/test/java/net/sourceforge/pmd/lang/java/types/testdata/DummyCompiledClass.java
vendored
Normal file
11
pmd-java/src/test/java/net/sourceforge/pmd/lang/java/types/testdata/DummyCompiledClass.java
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.java.types.testdata;
|
||||
|
||||
public class DummyCompiledClass {
|
||||
public String toString() {
|
||||
return getClass().toString();
|
||||
}
|
||||
}
|
@ -233,4 +233,40 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>[java] StringBuilder/Buffer false negatives with typeres #2881</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
package net.sourceforge.pmd.lang.java.types.testdata;
|
||||
|
||||
public class DummyCompiledClass {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int start = sb.indexOf(" ");
|
||||
if (start == -1) {
|
||||
sb.append("Bar");
|
||||
sb.append(" "); // warning expected: Avoid appending characters as strings in StringBuffer.append.
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>[java] StringBuilder/Buffer false negatives with typeres #2881 (countertest, no classpath)</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class NoCompiledClass {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int start = sb.indexOf(" ");
|
||||
if (start == -1) {
|
||||
sb.append("Bar");
|
||||
sb.append(" "); // warning expected: Avoid appending characters as strings in StringBuffer.append.
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
@ -1467,4 +1467,34 @@ public class Foo {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>[java] StringBuilder/Buffer false negatives with typeres #2881</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
package net.sourceforge.pmd.lang.java.types.testdata;
|
||||
|
||||
public class DummyCompiledClass {
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("test "); // warning expected: StringBuffer (or StringBuilder).append is called 3 consecutive times with literals. Use a single append with a single combined String.
|
||||
sb.append("test2 ").append("test3 ");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>[java] StringBuilder/Buffer false negatives with typeres #2881 (countertest, no classpath)</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class NoCompiledClass {
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("test "); // warning expected: StringBuffer (or StringBuilder).append is called 3 consecutive times with literals. Use a single append with a single combined String.
|
||||
sb.append("test2 ").append("test3 ");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
@ -1031,4 +1031,41 @@ public class Test {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>[java] StringBuilder/Buffer false negatives with typeres #2881</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-messages>
|
||||
<message>StringBuffer constructor is initialized with size 16, but has at least 17 characters appended.</message>
|
||||
</expected-messages>
|
||||
<code><![CDATA[
|
||||
package net.sourceforge.pmd.lang.java.types.testdata;
|
||||
|
||||
public class DummyCompiledClass {
|
||||
public String toString() {
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("test ");
|
||||
sb.append("test2 ").append("test3 ");
|
||||
appendToSpringBuffer(sb, "test4");
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>[java] StringBuilder/Buffer false negatives with typeres #2881 (countertest, no classpath)</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-messages>
|
||||
<message>StringBuffer constructor is initialized with size 16, but has at least 17 characters appended.</message>
|
||||
</expected-messages>
|
||||
<code><![CDATA[
|
||||
public class NoCompiledClass {
|
||||
public String toString(){
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("test ");
|
||||
sb.append("test2 ").append("test3 ");
|
||||
appendToSpringBuffer(sb, "test4");
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
2
pom.xml
2
pom.xml
@ -95,7 +95,7 @@
|
||||
<checkstyle.version>8.30</checkstyle.version>
|
||||
<checkstyle.plugin.version>3.1.1</checkstyle.plugin.version>
|
||||
<pmd.plugin.version>3.14.0</pmd.plugin.version>
|
||||
<ant.version>1.10.8</ant.version>
|
||||
<ant.version>1.10.9</ant.version>
|
||||
<javadoc.plugin.version>3.2.0</javadoc.plugin.version>
|
||||
<antlr.version>4.7.2</antlr.version>
|
||||
|
||||
|
Reference in New Issue
Block a user