pmd

How to Add custom JAR to the “eclipse-pmd” plugin?

谁说我不能喝 提交于 2019-12-04 13:50:07
Installed the Eclipse PMD plugin (written by Philip Graf ) from here . I tried to associate a custom PMD rule classes JAR but couldn't find a provision for it. This JAR contains custom rule classes (that extends AbstractJavaRule indirectly). So is there any way to configure eclipse-pmd plugin to accept this custom JAR? My custompmd.jar has this structure: custompmd.jar └─com/pmd/custom └─AvoidHardcodingRule.class └─AvoidCatchWithoutLogErrorRule.class └─etc... Simply putting it in plugins directory didn't help. One of the SO question suggests a solution but that's for a different plugin .

PMD in eclipse does not accept exclude-pattern

旧巷老猫 提交于 2019-12-04 08:21:45
I am using PMD under eclipse 4.3.1 / Kepler and I cannot exclude files and folders from the violation check. My folder structure /any/path/to/the/workspace/myproject1 /any/path/to/the/workspace/myproject2 /any/path/to/the/workspace/myprojectWithPMDrulesFile/pmd-rules.xml Now following folders get generated by testng ...../myproject1/test-output ...../myproject2/test-output Now I have configured following rules file: <?xml version="1.0" encoding="UTF-8"?> <ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Xeno-PMD-rules" xsi

Is SonarQube Replacement for Checkstyle, PMD, FindBugs?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 07:23:15
问题 We are working on a web project from scratch and are looking at the following static code analysis tools. Conventions (Checkstyle) Bad practices (PMD) Potential bugs (FindBugs) The project is built on Maven. Instead of using multiple tools for the purpose, I was looking at a single flexible solution and came across SonarQube. Is it true that we can achieve the results from Checkstyle, PMD and Findbugs with SonarQube? 回答1: Sonar will run CheckStyle, FindBugs and PMD, as well as a few other

PMD-Java代码静态分析工具使用

耗尽温柔 提交于 2019-12-04 04:19:16
如今,使用代码分析工具来代替人工进行代码审查,已经是大势所趋了。用于Java代码检测的工具中,不乏许许多多的佼佼者,其中PMD就是其中一款。PMD既可以独立运行,也可以以命令行的形式运行,还可以作为插件在IDE中运行,本文将基于在Android Studio中的使用来介绍PMD的基本使用。 一、PMD简介 对于PMD名称含义,有个有趣的现象,PMD不存在一个准确的名称,在官网上你可以发现很有有趣的名称 ,比如:Pretty Much Done,Project Meets Deadline等。PMD是一款程序代码检查工具(可以支持多种语言,以Java为例),通过静态分析Java源文件来获知代码错误,也就是说在不运行不编译Java程序的情况下直接扫描Java源文件,报告错误 。该软件功能强大,扫描效率高,是Java程序员debug的好帮手。它附带了许多可以直接使用的规则,利用这些规则可以找出Java源程序的许多问题,比如: 可能的 Bugs:检查潜在代码错误,如空 try/catch/finally/switch 语句 未使用代码(Dead code):检查未使用的变量,参数,方法 复杂的表达式:检查不必要的 if 语句,可被 while 替代的 for 循环 重复的代码:检查重复的代码 循环体创建新对象:检查在循环体内实例化新对象 资源关闭:检查 Connect,Result

PMD

﹥>﹥吖頭↗ 提交于 2019-12-04 04:10:26
PMD支持的编辑器包括:JDeveloper、Eclipse、JEdit、JBuilder、BlueJ、CodeGuide、NetBeans/Sun Java Studio Enterprise/Creator、IntelliJ IDEA(Android Studio是基于此编辑器)、TextPad、Maven、Ant,、Gel、JCreator和Emacs。 可能的 Bugs:检查潜在代码错误,如空 try/catch/finally/switch 语句 未使用代码(Dead code):检查未使用的变量,参数,方法 复杂的表达式:检查不必要的 if 语句,可被 while 替代的 for 循环 重复的代码:检查重复的代码 循环体创建新对象:检查在循环体内实例化新对象 资源关闭:检查 Connect,Result,Statement 等资源使用之后是否被关闭掉 三、PMD的安装 File > Settings > Plugins > Browse repositories 搜索 “PMD”,找到“PMDPlugin”这一项,按照提示进行安装,然后重启即可。 四、使用PMD检测代码 1、启动PMD检测功能 (1)从Tools菜单中启动 通过Tools > Run PMD可以看到如下的界面。从运行结果来看,如果通过该方式启动,扫描的范围就是整个个项目中的文件了。 Pre

Can't import PMD Ruleset in Eclipse

房东的猫 提交于 2019-12-03 12:33:02
I would like to use the same Ruleset in my IDE (Eclipse) that my Sonar profile. I got the PMD XML ruleset from the Sonar Permalinks and would like to import it into my PMD Eclipse Plugin but when i try to do it, the "OK" button is desactivated ... Can someone help me ? The problem could be that Sonar is exporting your ruleset for v4.x format and your Eclipse plugin expects them in v5.x format. Try changing your rules from: <rule ref="rulesets/basic.xml/UnusedNullCheckInEquals"> <priority>3</priority> </rule> to <rule ref="rulesets/java/basic.xml/UnusedNullCheckInEquals"> <priority>3</priority>

Java PMD warning on non-transient class member

杀马特。学长 韩版系。学妹 提交于 2019-12-03 10:24:43
On line: private boolean someFlag; I get the following PMD warning: Found non-transient, non-static member. Please mark as transient or provide accessors. Can someone please explain why this warning is there and what it means? (I understand how to fix it, I don't understand why it's there...) I'm getting this on many other member declarations as well... EDIT: My class is definitely not a bean, and not serializable... I assume your class is a bean that by definition implements Serializable . A transient variable will be excluded from the serialization process. If you serialize and then

ROS, opencv3 and CMake - unable to remove the library

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Working environment: Kubuntu 14.04 LTS 64bit ROS Indigo (up-to-date, full desktop install) OpenCV 2.4.8 For some unknown reason I decided to install the ros-indigo-opencv3 package which I regretted almost immediately due to the fact I also have the default version that comes with Ubuntu 14.04 - OpenCV 2.4.8. At first I noticed that QtCreator was warning me of possible incompatibility between 2.4.8 and 3.0.0 when I was building my CMake project (you can see the CMakeLists.txt at the end of this post) using only find_package(OpenCV REQUIRED)

Efficiency: switch statements over if statements

北战南征 提交于 2019-12-03 06:38:28
问题 PMD tells me A switch with less than 3 branches is inefficient, use a if statement instead. Why is that? Why 3? How do they define efficiency? 回答1: Because a switch statement is compiled with two special JVM instructions that are lookupswitch and tableswitch . They are useful when working with a lot of cases but they cause an overhead when you have just few branches. An if/else statement instead is compiled into typical je jne ... chains which are faster but require many more comparisons when

Is there a Findbugs and / or PMD equivalent for C/C++? [closed]

感情迁移 提交于 2019-12-03 04:23:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 months ago . I was recently asked about alternatives to Coverity Prevent for a code base that includes both C/C++ and Java. Obviously, on the Java side, the free tools available include Findbugs (compiled code analysis) and PMD (static code analysis). They are very powerful, especially when you start investigating