A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1632 below:

[java] ConsecutiveLiteralAppends false positive over catch · Issue #1632 · pmd/pmd · GitHub

Affects PMD Version: 6.11.0

Rule: ConsecutiveLiteralAppends

Description: When appending a literal before a try/catch block and also inside the try block, after calling a method, that might throw a exception, PMD falsely reports a ConsecutiveLiteralAppends lint.

Code Sample demonstrating the issue:

public final class Test {
    public String foo() {
        final StringBuilder sb = new StringBuilder();
        sb.append("literal1");
        try {
            final String res = bar();
            sb.append("literal2").append(res);
        } catch (Exception e) {
            sb.append("literal3");
        }
        return sb.toString();
    }

    public String bar() throws Exception {
        throw new Exception();
    }
}

Running PMD through: Gradle


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4