Steve Chambers Steve Chambers - 1 month ago 6
Java Question

Is there a Checkstyle/PMD rule "Non-abstract classes should not be named AbstractXXX"?

The Java project I'm working on uses a combination of code analysis tools: PMD, Checkstyle and FindBugs. These pick up on plenty of bugs, style issues etc. but one often slips through the net:

public class AbstractBadlyNamedClass { // Not abstract!
// ...
}


Note the other way round is checked, i.e.
public abstract BadlyNamedClass
gives PMD warning "Abstract classes should be named AbstractXXX".

Could anyone advise whether there is a way of checking for this, either with one of the mentioned tools (perhaps some kind of custom rule?) or another automated tool that would do the job?

Answer

I think the checkstyle AbstractClassName check is what you are looking for.