Add more test cases
This commit is contained in:
@@ -1446,6 +1446,46 @@ public final class Test {
|
||||
public String bar() throws Exception {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Consecutive literal append over try</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>4</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public final class Test {
|
||||
public String foo() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("foo"); // violation here
|
||||
try {
|
||||
sb.append("bar");
|
||||
final String res = methodThatMightThrow();
|
||||
sb.append(res);
|
||||
} catch (IOException ioe) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>literal appends over lambdas</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public final class Test {
|
||||
public String foo() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
Runnable r = () -> sb.append("foo");
|
||||
Runnable r2 = () -> sb.append("bar");
|
||||
|
||||
r.run();
|
||||
System.out.println(sb.toString());
|
||||
r2.run();
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Reference in New Issue
Block a user