Andriy Kryvtsun
Andriy Kryvtsun

Reputation: 3344

Checkstyle 'this' keyword overuse detection

Is there a Checkstyle module to detect code like this

private ServiceClass service = ...

public void someMethod(String param) {
    String result = this.service.find(param);
    if(!this.isValid(result)) {
        throw new RuntimeException();
    } else {
        return result;
    }
} 

private boolean isValid(String param) {
...
}

As you can see here this isn't needed actually as there are no any method and field overlappings.

The RequireThis module is close to my needs but looks like it can't detect such kind of over usage.

Upvotes: 1

Views: 289

Answers (1)

rveach
rveach

Reputation: 2201

this isn't needed actually as there are no any method and field overlappings.

There is no Checkstyle check that flags unnecessary usage of this. RequireThis check only identifies areas missing this, not the reverse.

Upvotes: 2

Related Questions