pmd

PMD in eclipse does not accept exclude-pattern

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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

Can&#039;t import PMD Ruleset in Eclipse

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 ? 回答1: 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

PMD ruleset file

匿名 (未验证) 提交于 2019-12-03 02:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to PMD. I am trying to figure where is the default ruleset file, name of the default ruleset file and how do we add our own rules to it. I tried to google but that is just confusing me. So far, I have put the pmd plugin inside eclipse plugins folder and in preferences I can see PMD. Can anyone please hep me with this? Thanks, Nisha 回答1: The standard ruleset file is *.xml inside pmd-bin-x.x.x.zip/.../lib/pmd-x.x.x.jar/rulesets/ , refer to http://pmd.sourceforge.net/rules/index.html . The default ruleset file of PMD Eclipse Plugin is

Can&#039;t use custom ruleset in maven-pmd-plugin 5.0.2

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want maven-pmd-plugin to include rulesets that I specify and exclude some rules (specifically, UselessParentheses) Just like described in documentation , I placed the following in pmd.xml that is parent for all modules: <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>3.0</version> <configuration> <rulesets> <ruleset>/home/ubuntu/ruleset.xml</ruleset> </rulesets> </configuration> </plugin> </plugins> </reporting> and prepared a custom ruleset like with this: <!--

PMD: DD/DU anomaly

匿名 (未验证) 提交于 2019-12-03 02:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Eclipse with the PMD Plug-in (4.0.0.v20130510-1000) and get a lot of those violations: Found 'DD'-anomaly for variable 'freq' (lines '187'-'189'). Found 'DU'-anomaly for variable 'freq' (lines '189'-'333'). In this SO answer, it says that those anomalies are related to assigning values that are never read. But I get the violations for instance in this case: // here I get a DD anomaly double freq = 0; try { // here I get a DU anomaly freq = Double.parseDouble(getFrequencyTextField().getText()); } catch (final NumberFormatException

PMD violationSuppressXPath for all REST @GET methods?

匿名 (未验证) 提交于 2019-12-03 02:15:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to narrow down the PMD rules, how can I exclude all REST methods which are annotated with @GET from PMD checks? 回答1: We are using for example this rules to suppress checks on REST methods for final declaration. Maybe you need similar? <rule ref="rulesets/java/optimizations.xml/MethodArgumentCouldBeFinal"> <properties> <!-- Ignore Rest resources --> <property name="violationSuppressXPath" value=" //ClassOrInterfaceBodyDeclaration/Annotation/MarkerAnnotation//Name[@Image='GET'] | //ClassOrInterfaceBodyDeclaration/Annotation

PMD: Avoid instantiating new objects inside loops

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got an issue with the PMD rule Avoid instantiating new objects inside loops . Here is some example code: import java.awt.Dimension; public class PMDDemo { public static void main(final String[] args) { final Dimension[] arr = new Dimension[10]; for (int i = 0; i PMD gives me the above mentioned rule violation at the marked spot in the code. How am I supposed to create n instances of a class without creating them within a loop? I know that some of PMD's rules are controversial (like the onlyOneExit rule). But up to now I at least

PMD - NPath complexity very high with ternary operator (?

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using PMD to generate some code quality report on a project. I don't understand a result for the NPath complexity inspection. I have created a dull class that is show-casing the result (this is not the real class, but it is using the same pattern): import java.util.*; public class SOFExample { private final Map magicMap = new HashMap (); protected static final long UNKNWOWN = 0L; private static final class MyCal { long aTime; long bTime; long cTime; long dTime;} public void usefullMethod(final List myCals) { final Date a = magicMap.get(

Maven pmd plugin - Exclude/Disable a rule

匿名 (未验证) 提交于 2019-12-03 00:51:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm attempting to exclude a certain rule from pmd using the maven-pmd-plugin (in a multi-module maven project). Approach: Using the excludeFromFailureFile http://maven.apache.org/plugins/maven-pmd-plugin/examples/violation-exclusions.html Ideally, I want to exclude this rule for the entire product (based on a parent package), however,to being with I tested for a particular class - even that is not working. Environment Java 7, Maven 3.0.3 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>3

IDEA插件之PMD

匿名 (未验证) 提交于 2019-12-03 00:15:02
1、是什么?   PMD 是一个开源静态源代码分析器 ,它报告在应用程序代码中发现的问题。PMD包含内置规则集,并支持编写自定义规则的功能。PMD不报告编译错误,因为它只能处理格式正确的源文件。PMD报告的问题是效率很低的代码或不良的编程习惯,如果累积这些问题,它们可能会降低程序的性能和可维护性。 2、安装插件 在代码编辑框或Project 窗口的文件夹、包、文件右键,选择“Run PMD”,“Pre Defined”,“All”,对指定的文件夹、包、文件进行分析: 来源:博客园 作者: 我的蜡笔丢了 链接:https://www.cnblogs.com/GuixinChan/p/11755145.html