PMD -- An extensible cross-language static code analyzer.

PMD

An extensible cross-language static code analyzer.

https://github.com/pmd/pmd

跨语言静态代码分析工具。可以查找通用的编码错误,例如 未使用的变量、空catch块、非必须的对象创建、等等。

另外,它也包括CPD工具, 复制-黏贴-检查工具。可以检查出代码中的重复部分。

PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth. It supports Java, JavaScript, Salesforce.com Apex and Visualforce, PLSQL, Apache Velocity, XML, XSL.

Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code in Java, C, C++, C#, Groovy, PHP, Ruby, Fortran, JavaScript, PLSQL, Apache Velocity, Scala, Objective C, Matlab, Python, Go, Swift and Salesforce.com Apex and Visualforce.

 

Welcome to PMD

https://pmd.github.io/pmd-5.8.1/

能处理以下潜在的问题:

1、 可能的bug -- 空特定语句块。

2、无效代码 -- 未使用的局部变量、参数、私有方法。

3、次优代码 -- 浪费使用 String StringBuffer。

4、过于复杂的表达式 -- 非必要的if语句、for语句。

5、重复代码 -- 拷贝-复制方式生成的代码。

PMD scans source code in Java and other languages and looks for potential problems like:

  • Possible bugs - empty try/catch/finally/switch statements
  • Dead code - unused local variables, parameters and private methods
  • Suboptimal code - wasteful String/StringBuffer usage
  • Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
  • Duplicate code - copied/pasted code means copied/pasted bugs

 

重复代码检查

https://pmd.github.io/pmd-5.8.1/usage/cpd-usage.html

For Linux, there is since PMD 5.0 a combined start script for all command line tools. This includes CPD. The start script is called run.sh and is located in the bin subdirectory in the PMD binary distribution zip-file. Let’s assume, you are in this directory, then you can start CPD this way:

  1. ./run.sh cpd --minimum-tokens 100 --files c:\temp\src\java

The options “minimum-tokens” and “files” are the two required options; there are more options, see below.

。。。。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值