Is there a simple CLI Java linter?

BlueDragonX picture BlueDragonX · Feb 4, 2013 · Viewed 60.6k times · Source

I've been trying to find a Java linter capable of running on the CLI that is separate from Eclipse that I can call as a commit hook for git or from our automated build script. Does such a thing exist?

Ideally it needs to check for unused imports and variables, that style guidelines are followed, exceptions are used properly, etc. Though some subset of those features would be better that what we have now - nothing!

Answer

mikeslattery picture mikeslattery · Feb 4, 2013
  • SpotBugs (earlier Findbugs) for finding existing bugs. VERY GOOD!
  • PMD for finding patterns that can lead to bugs (e.g. unused variables)
  • Checkstyle to enforce coding standards and conventions (e.g. whitespace, Javadoc)
  • Error Prone hooks right into your application's compile step

All these tools have some overlapping rules. There are many other similar tools, but these are the most popular and supported.