A RetroSearch Logo

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

Search Query:

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

GitHub ยท Where software is built

Affects PMD Version: 6.26.0 (and 6.27.0-SNAPSHOT)

Rule: UnusedAssignment

Description:
A method-call within a try-block might fail and its result shouldn't be treated as a guaranteed assignment.

Code Sample demonstrating the issue:

public class Foo {

    public int foo() {
        int a = 0; // <--- false-positive UnusedAssignment
        try (Reader r = new StringReader("")) {
            a = r.read(); // might assign or fail
            a = r.read(); // might assign or fail
        } catch (IOException e) {
        }
        return a;
    }

}

Expected outcome:

Running PMD through: Other


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