pmd

Can't import PMD Ruleset in Eclipse

若如初见. 提交于 2020-01-01 04:26:29
问题 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

Code analyzers: PMD & FindBugs

随声附和 提交于 2019-12-31 22:37:31
问题 1. Regarding PMD: 1.1 How do I set the PMD checks, to ignore some of them, like "Variable name is too short, or too long", "Remove empty constructor, etc" - and if I do that, another warning appears that says the class must have some static methods. Basically, the class was empty, for later development, and I like to leave it that way for now. 1.2 Is it necesarry to follow this warning advice? A class which only has private constructors should be final 1.3 What is that supposed to mean? The

Maven PMD plug-in not generating a report with 'mvn site' command or 'pmd:pmd'

房东的猫 提交于 2019-12-30 18:27:24
问题 I am reading an interesting tutorial here: http://www.avajava.com/tutorials/lessons/how-do-i-generate-pmd-and-cpd-reports-for-a-site.html?page=1 This tutorial shows how to use Maven to run the open-source static-analysis tool, PMD, and to see the generated output on a Maven created website. Maven can easily create websites with mvn site command, but this tutorial shows how to use PMD for more helpful metrics on the source code. The instructions were followed to the best of my ability. Here is

Java for each loop being flagged as UR anomaly by PMD

安稳与你 提交于 2019-12-30 16:23:21
问题 I would like to confirm if this is a bug on PMD? How do I file a ticket if it is. public static void main(final String[] args) { for (final String string : args) { string.getBytes(); //UR Anomaly } for (int i = 0; i < args.length; i++) { args[i].getBytes(); } } Lines 1-3 are being flagged as UR anomaly, while rewriting it to iterate with a local variable is fine. Would like to eliminate as much PMD violations, but it is inconvenient to have to resort to old loop construct as a workaround.

Java for each loop being flagged as UR anomaly by PMD

牧云@^-^@ 提交于 2019-12-30 16:23:08
问题 I would like to confirm if this is a bug on PMD? How do I file a ticket if it is. public static void main(final String[] args) { for (final String string : args) { string.getBytes(); //UR Anomaly } for (int i = 0; i < args.length; i++) { args[i].getBytes(); } } Lines 1-3 are being flagged as UR anomaly, while rewriting it to iterate with a local variable is fine. Would like to eliminate as much PMD violations, but it is inconvenient to have to resort to old loop construct as a workaround.

java :Why the Local variable should be declared final [duplicate]

∥☆過路亽.° 提交于 2019-12-30 08:55:01
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Is there any performance reason to declare method parameters final in Java? Why would one mark local variables and method parameters as “final” in Java? I am using PMD to see the code violations. Inside a webService Method, I have this below code public ServiceRequest getData() { Status status = new Status(); // code } What PMD is suggesting me is that, this local variable status could be declared as final. My

The “Why” behind PMD's rules

六眼飞鱼酱① 提交于 2019-12-30 02:43:06
问题 Is there a good resource which describes the "why" behind PMD rule sets? PMD's site has the "what" - what each rule does - but it doesn't describe why PMD has that rule and why ignoring that rule can get you in trouble in the real world. In particular, I'm interested in knowing why PMD has the AvoidInstantiatingObjectsInLoops and OnlyOneReturn rules (the first seems necessary if you need to create a new object corresponding to each object in a collection, the second seems like it is a

creatRuleViolation how to define it? Save me from this

余生长醉 提交于 2019-12-25 11:15:08
问题 Help. I would like to sacrifice the reputation for a proper answer.. public class ParameterNameConvention extends AbstractJavaRule { private final static String PATTERN = "[p][a-zA-Z]+"; public Object visit(ASTMethodDeclaration node, Object data) { RuleContext result = (RuleContext) data; String rulePattern = (!getStringProperty("rulePattern") .equalsIgnoreCase("")) ? getStringProperty("rulePattern") : PATTERN; if (node.containsChildOfType(ASTFormalParameter.class)) { Iterator iterator = node

PMD Eclipse Plugin error: An internal error occurred during: “ReviewCode”

寵の児 提交于 2019-12-24 21:48:43
问题 I need your help to solve my problem: I'm modifying the Eclipse PMD Plugin for introduce my own rulesets in the plugin, and when I have installed my modified plugin, the IDE starts OK, but when I test it in any Java project to check the PMD with the option "Check Code with PMD", Eclipse shows me this error message: An internal error occurred during: "ReviewCode". tried to access field net.sourceforge.pmd.CommonAbstractRule.properties from class com.mypackage.cal.cca.crregvalijav.uti.ClassASL2

How to included bundled rulesets in maven pmd plugin

此生再无相见时 提交于 2019-12-24 12:40:08
问题 I have a custom ruleset definition that refers to a bunch of rules from bundled rulesets. However, I have problems with resolving these bundled rulesets in the maven pmd plugin. Here is a related question with a quick'n'dirty solution for this problem. However, I was wondering whether there might be a clean solution for this problem (because I think that this is a rather common usecase, or?). In the following I'm describing the attempts that I tried so far: <build> <pluginManagement> <plugins