Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 757
Idan Avatar asked Dec 06 '15 16:12

Idan


People also ask

What is PMD CheckStyle?

PMD, FindBugs and Checkstyle, are the most popular open-source code analyzers, they are extensively used in Java development to improve the codebase and identify potential vulnerabilities along with design flaws; every tool has its feature, purpose and strength, targeting a specific type of coding rules.

What is inspect code in IntelliJ?

Code inspections In IntelliJ IDEA, there is a set of code inspections that detect and correct abnormal code in your project before you compile it. The IDE can find and highlight various problems, locate dead code, find probable bugs, spelling problems, and improve the overall code structure.

How do I run a PMD in IntelliJ?

The user can run pmd on a single or set of files/folders and see the results in intelliJ. To run the predefined rulesets, go to Tools -> PMD -> PreDefined menu. PMD supports custom ruleset file, to configure goto settings -> PMD and add the rule set files that are required.

How do I inspect values in IntelliJ?

IntelliJ IDEA allows you to inspect variables in a dedicated dialog. This is useful when you need to keep track of some variable (or the object whose reference it holds) and at the same time be able to navigate between frames and threads. Right-click a variable on the Variables tab and select Inspect.


1 Answers

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.

like image 129
Michal Kordas Avatar answered Oct 19 '22 18:10

Michal Kordas