Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 283
Steve Chambers Avatar asked Mar 31 '15 16:03

Steve Chambers


People also ask

What is PMD CheckStyle?

PMD, FindBugs and Checkstyle, are the most popular open-source code analyzers, they are extensively used in Java development to improve the codebase and identify potential vulnerabilities along with design flaws; every tool has its feature, purpose and strength, targeting a specific type of coding rules.

What is the main advantage of Sonarqube over CheckStyle PMD and FindBugs?

By default, for Java projects, Sonar executes FindBugs, CheckStyle, and PMD, as well as a few other "plugins", such as Cobertura. The main advantage is that it stores the history in a database.


1 Answers

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

like image 174
Mani Avatar answered Sep 18 '22 14:09

Mani