7
votes

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?

1
How about "search" in Eclipse?Antoniossss
I would actually support reversing it. There are plenty of reasons to not name an abstract class AbstractXXX. But a class named AbstractXXX better be abstract! Otherwise, you will confuse little old me :)Brandon
@Antoniossss - That would work but its hardly automated and not something thats easy to roll into a continuous integration process.Freiheit
You want some kind of mass refactoring?Antoniossss
@Antoniossss no just something that runs as part of the Eclipse and Maven build.Steve Chambers

1 Answers

5
votes

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