

Like Checkstyle, PMD is a popular static code analyzer with an emphasis on Java.

What do the PMD initials stand for? It seems even the developers don’t know… Lightrun lets you debug issues in production and run data analysis on your code without slowing down or interrupting your application. Lightrun allows you to insert logs, metrics, and snapshots into your code, even at runtime, directly from your IDE or CLI. Production is the ultimate stress test for any codebase, especially in the age of cloud computing. At the end of the day, static code analysis and linting can only get you so far, so if you need a little more, Lightrun is worth adding to your workflow. Whereas everything to this point has been a static code analyzer, Lightrun is a runtime debugger. The second member of this list is not actually a linter per se, but it will help you improve your code quality and prevent bugs before they become serious problems. This might be a problem if you’re only looking to catch larger errors and don’t have the resources to fix tiny errors that don’t have a perceptible impact. It is also worth mentioning that a project with Checkstyle built into its build process will fail to build even if minor errors are present.

It is also available as a plugin for a wide variety of IDE’s and toolsets, including Eclipse, Codacy, Maven, and Gradle – although these plugins are managed by third parties, so there’s no guarantee of long-term support.Ĭheckstyle comes with pre-made config files that support both Sun Code Conventions and Google Java Style, but because these files are XML, they are highly configurable to support your workflow and production needs. Checkstyle works natively with Ant and CLI. With this popularity comes regular updates, thorough documentation, and ample community support. CheckstyleĬheckstyle is one of the most popular linters available. Ultimately, it’s best to choose a linter that works best for your specific business use case and workflow. You’ll find that while most linters aren’t “better” or “worse” than others, there are certainly some that come with a wider breadth of features, making them more powerful or flexible than some of their niche counterparts. In this article, I’ll examine ten of the best linters for Java. If (leaves = null) throw new IllegalArgumentException("No leaves!") If (trunk = null) throw new IllegalArgumentException("No trunk!") If (roots = null) throw new IllegalArgumentException("No roots!") In other words, using a linter helps make your code less sloppy and more maintainable.Ĭheck out the below example for a demonstration of how a linter works, from Checkstyle: While the use cases for linters can be rather varied, their utility usually focuses on code cleanup and standardization. They can work inside your IDE, run as part of your build process, or be inserted into your workflow anywhere in between. Linters are best described as static code analyzers because they check your code before it even runs. One of the best ways to achieve this, while also potentially finding bugs and other issues with your code, is to use a linter. If you want to ensure code maintainability over the long term, you should follow best coding practices and style guide rules.
