1. 程式人生 > >PMD 編譯 語法分析 詞法分析 抽象語法樹

PMD 編譯 語法分析 詞法分析 抽象語法樹

edit get 編譯 test if語句 final 代碼掃描 pic blog

編譯原理 163 課堂 http://mooc.study.163.com/learn/-1000002001?tid=1000003000#/learn/content?type=detail&id=1000024005&cid=1000019010

靜態代碼掃描 (一)——PMD 自定義規則入門

PMD from http://pmd.sourceforge.net/

PMD能夠掃描Java 源代碼,查找類似以下的潛在問題:

  • 可能的bug——try/catch/finally/switch語句中返回空值。
  • 死代碼——未使用的局部變量、參數、私有方法。
  • 不理想的代碼——使用String/StringBuffer。
  • 過於復雜的表達式——沒有必要使用if語句、while循環可以代替for循環。
  • 重復代碼——復制/粘貼的代碼引發的bug。

PMD集成了JDeveloper, Eclipse, JEdit, JBuilder, BlueJ, CodeGuide, NetBeans/Sun Java Studio Enterprise/Creator, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, 以及 Emacs。

PMD 編譯 語法分析 詞法分析 抽象語法樹