常用静态代码测试工具

spotbugs

SpotBugs 是一个使用静态分析来查找 Java 代码中的错误的程序。 它是自由软件,根据 GNU 宽通用公共许可证的条款分发。 SpotBugs 是 FindBugs(现在是一个废弃的项目)的一个分支,在其社区的支持下从它停止的点继续进行。 详情请查看官方手册。 SpotBugs 需要 JRE(或 JDK)1.8.0 或更高版本才能运行。 但是,它可以分析为任何 Java 版本(从 1.0 到 1.9)编译的程序。

SpotBugs

FindBugs™ - Find Bugs in Java Programs

该程序使用静态分析来查找 Java 代码中的错误。 它是自由软件,根据小 GNU 公共许可证的条款分发。 FindBugs™ 名称和 FindBugs 徽标是马里兰大学的商标。 FindBugs 已被下载超过一百万次。 FindBugs 的当前版本是 3.0.1。 FindBugs 需要 JRE(或 JDK)1.7.0 或更高版本才能运行。 但是,它可以分析为任何 Java 版本(从 1.0 到 1.8)编译的程序。 FindBugs 的当前版本是 3.0.1,于 2015 年 3 月 6 日美国东部标准时间 13:05:33 发布。

FindBugs

PMD

PMD

PMD is a static source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth. It’s mainly concerned with Java and Apex, but supports six other languages.

PMD features many built-in checks (in PMD lingo, rules), which are documented for each language in our Rule references. We also support an extensive API to write your own rules, which you can do either in Java or as a self-contained XPath query.

PMD is most useful when integrated into your build process. It can then be used as a quality gate, to enforce a coding standard for your codebase. Among other things, PMD can be run:

CPD, the copy-paste detector, is also distributed with PMD. You can also use it in a variety of ways, which are documented here.

PMD 是一个静态源代码分析器。 它会发现常见的编程缺陷,例如未使用的变量、空的 catch 块、不必要的对象创建等等。 它主要关注 Java 和 Apex,但支持其他六种语言。 PMD 具有许多内置检查(用 PMD 术语,规则),这些检查在我们的规则参考中针对每种语言进行了记录。 我们还支持广泛的 API 来编写您自己的规则,您可以使用 Java 或作为自包含的 XPath 查询来完成。 PMD 在集成到您的构建过程中时最有用。 然后它可以用作质量门,为您的代码库强制执行编码标准。 除其他外,PMD 可以运行: 作为 Maven 目标 作为 Ant 任务 作为 Gradle 任务 从命令行 CPD,复制粘贴检测器,也与 PMD 一起分发。 您还可以通过多种方式使用它,此处记录了这些方式。

Checkstyle

Checkstyle

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.

Checkstyle is highly configurable and can be made to support almost any coding standard. An example configuration files are supplied supporting the Sun Code Conventions, Google Java Style.

A good example of a report that can be produced using Checkstyle and Maven can be seen here .

Checkstyle 是一种开发工具,可帮助程序员编写符合编码标准的 Java 代码。 它使检查 Java 代码的过程自动化,从而使人们免于执行这项无聊(但很重要)的任务。 这使其成为想要强制执行编码标准的项目的理想选择。 Checkstyle 是高度可配置的,可以支持几乎任何编码标准。 提供了支持 Sun 代码约定、Google Java 样式的示例配置文件。 可以在此处查看可以使用 Checkstyle 和 Maven 生成的报告的一个很好的示例。

其他

sonarqube集成

Importing External Issues

sonarqube findbugs插件

Changelog

Use SpotBugs 4.7.0, sb-contrib 7.4.7, and findsecbugs 1.12.0