Intellij IDEA build-in inspection code vs checkstyle, PMD & findbugs
Asked Answered
P

1

17

Recently i'm looking about the best tool set to do code inspection. My IDE is Intellij 15.0 and i know there is a good inspection capabilities there but when i look over the internet i didn't found good comparison between Intellij build-in inspection code and those three. Can someone that tried them all can give some best practice what to use? is Intellij cover all of them?

I know findbugs run in binary level but still let it stay in the comparison.

Puggree answered 6/12, 2015 at 16:5 Comment(0)
G
22

In Checkstyle project itself, we use all of these tools: Checkstyle, PMD, FindBugs and IntelliJ IDEA inspections.

Here are my observations:

  • There is no replacement for Checkstyle when it comes to formatting, whitespaces, braces placement, Javadoc and general code style. There's some overlap with IntelliJ at naming and some bad practices, but that's it.
  • PMD rules are quite similar to the IntelliJ's ones. Both tools aim mainly to detect typical mistakes or bad practices. You will still find some unique useful PMD rules though, just some random examples: BigIntegerInstantiation, CommentDefaultAccessModifier, SingletonClassReturningNewInstance.
  • I would never resign from FindBugs in favour of some other tool. FindBugs focuses just on finding real bugs in code with low rate of false-positives. Usually, it doesn't require almost any configuration - just enable all rules and sleep safe. Of course there is some overlap with IntelliJ, but the more bugs detected, the better.

IntelliJ IDEA inspections are a great tool, as they contain lots of unique and reliable rules. And it's not only Java - you can out of the box detect problems in XML, Properties, SQL, Spring, HTML, CSS, etc. They require a lot of configuration and picking a right rule set though. Enabling all rules would report hundreds of thousands violations on every larger project. And it's hard to embed these inspections in Maven or Gradle build so that project is self-validating.

My recommendation is to make use of all of these tools, as each of them contains at least a dozen (sometimes dozen of dozens) of useful checks that are not available anywhere else.

Got answered 6/12, 2015 at 22:25 Comment(2)
Thanks for the answer Michal. Do you use the IntelliJ plug-ins for all of those tools? If we insert to the picture tool like SonarQube that will run in the CI do you still use all of them in the IDE?Puggree
I just use CheckStyle-IDEA, because it can do quick real-time analysis along with quick verification of all files before commit. Checkstyle problems are the most common ones, so it's really helpful. For PMD and FindBugs I invoke mvn pmd:check findbugs:check or equivalent for Gradle. Violations in these tools are less common but more serious, so in case I forget about something, CI will fail the build anyway.Got

© 2022 - 2024 — McMap. All rights reserved.