Joeyta備忘記

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            9 Posts :: 0 Stories :: 9 Comments :: 0 Trackbacks

          一般在編寫程式的時侯,經驗再豐富的編程員都會範上一些編程的陷阱,
          因此產生俗稱為 "smell code" 的代碼.

          PMD 是一套不錯的代碼檢查工具,專門檢測 "smell code",
          並能找出以下潛在的問題:
          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

          PMD 能集成於 JDeveloper, Eclipse, JEdit, Jbuilder, BlueJ, CodeGuide,
          NetBeans/Sun Java Studio Enterprise/Creator, Intellij IDEA, TextPad,
          Maven, Ant, Gel, JCreator, Emacs.

          由於太多IDE選擇, 所以本人選擇最熟悉的 Eclipse 作為本次備忘記.


          開始備忘記:

          下載 pmd-eclipse-site-3.2.2.zip
          http://sourceforge.net/project/showfiles.php?group_id=56262

          進入 Eclipse:
          Eclipse:Help -> Software Updates -> Find and Install -> Search for new feature to install
          點選 New Archived Site 瀏覽並選擇 pmd-eclipse-site-3.2.2.zip
          按 Finish 開始安裝

          開始檢查 smell code:
          Eclipse 裡點選需要檢查 smell code 的 project 或 java 檔案.
          右鍵選擇 PMD -> Check Code With PMD
          ( 或 )
          右鍵點選 project -> Properties -> PMD
          點選 Enable PMD
          按 OK 後如下圖所示

          從 Problems 裡可以看到所有 smell code.
          然後便可更正有問題的 smell code, 養成良好的 coding 習慣.

          參考資料:
          http://pmd.sourceforge.net/

          http://pmd.sourceforge.net/integrations.html#eclipse

          posted on 2007-07-21 18:44 joeyta 閱讀(1330) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 石柱| 繁峙县| 调兵山市| 井研县| 什邡市| 宁远县| 隆化县| 拜城县| 临桂县| 卢龙县| 洛隆县| 乌拉特前旗| 遵义县| 勐海县| 双江| 荃湾区| 高尔夫| 来安县| 井冈山市| 安溪县| 蛟河市| 轮台县| 特克斯县| 武夷山市| 昌江| 邻水| 休宁县| 台南市| 柳州市| 阿拉善左旗| 北京市| 云霄县| 本溪| 虎林市| 自贡市| 高雄市| 凌海市| 津市市| 蓬溪县| 石屏县| 龙里县|