New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] false positive for UselessQualifiedThis #1372

kevin-wayne opened this Issue Oct 7, 2018 · 3 comments


None yet
3 participants
Copy link

kevin-wayne commented Oct 7, 2018

Affects PMD Version:

UselessQualifiedThis, UnusedPrivateField

False positive when instance variable is an array (or multidimensional array) with the same name as the class. While the code below doesn't follow standard Java naming conventions, it doesn't use the this keyword, so the UselessQualifiedThis rule should not be relevant.

There is also a false positive for UnusedPrivateField.

Code Sample demonstrating the issue:

public class Board {
    private int[] Board;

    public Board(int[] b) {
        for (int i = 0; i < b.length; i++)
            Board[i] = b[i];

    public int size() {
        return Board.length;

Running PMD through:


This comment has been minimized.

Copy link

oowekyala commented Nov 2, 2018

The parsing for qualified this syntax appears to be very unhelpful. The .this is parsed as a primary suffix, which doesn't have a usesThisModifier method or an image, so there's no way to find that it's actually a qualified this without proceeding by elimination - which is what the rule does, and it fails here. Well at least it's easy to fix (#1427)

@oowekyala oowekyala added the has:pr label Nov 2, 2018

@oowekyala oowekyala added this to the 6.10.0 milestone Nov 2, 2018


This comment has been minimized.

Copy link

kevin-wayne commented Nov 2, 2018

Thanks, much appreciated.


This comment has been minimized.

Copy link

jsotuyod commented Nov 5, 2018

I created #1433 for the UnusedPrivateField false positive, to track it independently

@jsotuyod jsotuyod closed this in e1b5717 Nov 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment