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