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 閱讀(1327) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 历史| 甘洛县| 隆回县| 宿松县| 永靖县| 博野县| 鄄城县| 无棣县| 馆陶县| 辽阳县| 哈密市| 桂东县| 瓦房店市| 乌拉特后旗| 奉化市| 伊吾县| 湘潭县| 晋州市| 大方县| 枣强县| 贡嘎县| 康平县| 安义县| 三原县| 收藏| 大冶市| 托克逊县| 遂昌县| 盐边县| 平南县| 安国市| 沧州市| 蕲春县| 大英县| 平顶山市| 渝中区| 宾川县| 太康县| 太仓市| 江阴市| 阜平县|