简体   繁体   English

Intellij IDEA内置检测代码与checkstyle,PMD和findbugs

[英]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. 我的IDE是Intellij 15.0,我知道那里有很好的检查功能,但是当我查看互联网时,我没有找到Intellij内置检查代码和那三个之间的良好比较。 Can someone that tried them all can give some best practice what to use? 尝试过这些操作的人可以提供一些最佳实践吗? is Intellij cover all of them? Intellij是否涵盖所有这些?

I know findbugs run in binary level but still let it stay in the comparison. 我知道findbugs以二进制级别运行但仍然让它保持比较。

In Checkstyle project itself, we use all of these tools: Checkstyle , PMD , FindBugs and IntelliJ IDEA inspections . Checkstyle项目本身,我们使用所有这些工具: CheckstylePMDFindBugsIntelliJ IDEA检查

Here are my observations: 以下是我的观察:

  • There is no replacement for Checkstyle when it comes to formatting, whitespaces, braces placement, Javadoc and general code style. Checkstyle在格式化,空格,大括号放置,Javadoc和通用代码样式方面没有替代品。 There's some overlap with IntelliJ at naming and some bad practices, but that's it. IntelliJ在命名和一些不良做法方面存在一些重叠,但就是这样。
  • PMD rules are quite similar to the IntelliJ's ones. PMD规则与IntelliJ的规则非常相似。 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 . 您仍会找到一些独特的有用PMD规则,只是一些随机示例: BigIntegerInstantiationCommentDefaultAccessModifierSingletonClassReturningNewInstance
  • I would never resign from FindBugs in favour of some other tool. 我绝不会从FindBugs辞职而转而使用其他工具。 FindBugs focuses just on finding real bugs in code with low rate of false-positives. FindBugs专注于在低代码误报率的代码中发现真正的错误。 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有一些重叠,但检测到的bug越多越好。

IntelliJ IDEA inspections are a great tool, as they contain lots of unique and reliable rules. IntelliJ IDEA检查是一个很好的工具,因为它们包含许多独特而可靠的规则。 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. 而且它不仅是Java - 您可以开箱即用地检测XML,属性,SQL,Spring,HTML,CSS等中的问题。它们需要大量配置并选择正确的规则集。 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. 并且很难将这些检查嵌入到Maven或Gradle构建中,以便项目可以自我验证。

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. 我的建议是使用所有这些工具,因为每个工具都包含至少十二个(有时十几个)有用的检查,这些检查在其他任何地方都无法使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM