Skip to main content

Jun 24, 2020 - 2 minute read - IntelliJ Java For Testers Java

Using Static Analysis to improve your Java Coding

I’m always looking for simple ways that I can improve my Java programming. And SpotBugs, CheckStyle and PMD can help me do that.

NOTE: updated 20200625 because I no longer use QAPlug or FindBugs, I install PMD, CheckStyle and SpotBugs directly from the IntelliJ plugins.

I’m always looking for simple ways that I can improve my Java programming.

I use PMD and SpotBugs and CheckStyle IntelliJ Plugins my IDE.

Using Static Analysis

Using Static Analysis is like having a coach sitting by you when you are writing code. And some of the suggestions the tools make you won’t understand, so you have to search and learn what they mean - forcing you to learn that little bit more about your chosen language.

Don’t take all the suggestions at face value. You choose which suggestions to act on, and you can configure the tools to warn you about some things and not others.

Over time, you might choose to add the command line and build versions of the tools into your CI process rather than just your personal coding approach.

PMD Plugin

  • right click on the project
  • choose “PMD”
  • choose profile
  • analyse the results

PMD Demo

CheckStyle Plugin

  • configure using Preferences \ Tools \ Checkstyle
  • set to scan scope including tests
  • click the Checkstyle tab
  • Check Project
  • Analyse the results

CheckStyle Demo

SpotBugs Plugin

  • click the SpotBugs tab
  • analyse project file including test sources
  • Analyse the Results

SpotBugs Demo

Demo of QAPlug plugin with PMD, FindBugs and CheckStyle

Watch on YouTube

QAPlug wraps it all up in an right click menu item to Analyze the source code and shows all the items in a list for you to work through.

Just make sure you double click on the lowest branch in the tree to jump right to the code position where the tool identified the issue or suggestion.


You will need a Github account to comment. Or you can contact me with your comment.

I reserve the right to delete spam comments e.g. if your comment adds no value and its purpose is simply to create a backlink to another site offering training, or courses, etc.