A concise tutorial on pmd

Source: Internet
Author: User

1. decompress the package;
2, cd./qatools/pmd-bin-5.0.4/bin
3. Modify exec_pmd.sh to modify the directory to be checked.

Take useless code check as an example. The original content is:./run. sh pmd-d/home/wuhe. jyh/xxx/yyy/-rulesets java-unusedcode> unusedcode.txt

The red font part is the directory to be checked. The source code is checked by the pmd component. you can point to the source code project root directory that you are responsible for based on your needs.

4../exec_pmd.sh

After the script is executed, the op.txt,ex.txt,str.txt,unusedcode.txt file will be output under the bindirectory,

  • Op.txt contains code that can be optimized,

  • Ex.txt is the code that can be optimized for exception handling,

  • Str.txt is the code that can be optimized for string processing,

  • Unusedcode.txt is useless code.

Fix related bugs or optimize codes based on the check results.


Content in exec_pmd.sh:

./Run. sh pmd-d/home/wuhe. jyh/xx/yy/-rulesets java-android> android.txt
./Run. sh pmd-d/home/wuhe. jyh/xx/yy/-rulesets java-finalizers> finalizers.txt
./Run. sh pmd-d/home/wuhe. jyh/xx/yy/-rulesets java-optimizations> optimizations.txt
./Run. sh pmd-d/home/wuhe. jyh/xx/yy/-rulesets java-strictexception> strictexception.txt
./Run. sh pmd-d/home/wuhe. jyh/xx/yy/-rulesets java-strings> strings.txt
./Run. sh pmd-d/home/wuhe. jyh/xx/yy/-rulesets java-unnecessary> unnecessary.txt
./Run. sh pmd-d/home/wuhe. jyh/xx/yy/-rulesets java-unusedcode> unusedcode.txt


This article is from "recalling the past ..." Blog, please be sure to keep this source http://memory.blog.51cto.com/6054201/1290038

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.