pmd

Should anntoation SuppressWarnings for PMD work with string constants.

I would prefer to write @SuppressWarnings(PMD.ShortVariable) // with public static final String ShortVariable = "PMD.ShortVariable"; in class PMD. instead of @SuppressWarnings("PMD.ShortVariable") But when using constants PMD ignores the annotation. Have I made a mistake or is there another reason? ...

The "Why" behind PMD's rules.

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 OnlyOne...

Logger vs. System.out.println

Hi all, I'm using the PMD plugin for eclipse and it gives me an error when using System.out.println() with the explanation: System.(out|err).print is used, consider using a logger. My question is - What is a Logger? How is it used to print to the screen? Why is it better? Thanks. ...

Can PMD be customized to fully support a new language?

Can PMD be customized to fully support a new language, in a reasonable amount of time. I mean I know that technically almost anything can be done, but im wondering if this can be done in a reasonable amount of time? E.g. < 2 weeks This page mentions how to write a CPD parser http://pmd.sourceforge.net/cpd-parser-howto.html But is this...

can we include maven pmd plugin execution within build goal ?

Guys, I wanted generate the pmd report while building the project so I have added plugin to build section of my pom.xml but still it don't execute until I explicitly call mvn clean install pmd:pmd. I want to execute it with mvn clean install itself. is it possible ? my pom entries are as under: <build> <plugins> <plugin> ...

Using a custom PMD ruleset file within Ant

I'd like to use a custom PMD ruleset file for my build. Basically, I want to use many of the built-in ruleset packages with some rules turned off. For example, suppose I only wanted the strings and basics rules, I have this ruleset file, called ruleset.xml: <?xml version="1.0"?> <ruleset name="Custom ruleset" xmlns="http://pm...

What is the right position of literals in String Comparison?

I have if (localName.equals("TaxName")) { but PMD says Position literals first in String comparisons ...

PMD xpath rule to warn about the use of equals() on BigDecimal

Could someone suggest a PMD xpath rule to warn that calling the equals() method of java.math.BigDecimal will check for both value and scale which usually (unless for some engineering type apps) might be a mistake. sine 1.0 not equals 1.00, one should use compareTo. ...

Reasoning behind ArrayIsStoredDirectly rule of PMD

PMD has a rule called ArrayIsStoredDirectly in the Sun Security ruleset: Constructors and methods receiving arrays should clone objects and store the copy. This prevents that future changes from the user affect the internal functionality. Here is their example: public class Foo { private String [] x; public void foo (String [] ...

PMD and auto generated code in Netbeans

Hi everybody. I'm using Netbeans to build a GUI application and PMD "complains" about things in the auto-generated code. Can I configure PMD to ignore auto-generated code (as I did with Checkstyle)? Thank you. ...

Custom Rules With PMD - Passing values to a rule at runtime

Hello, My requirement is to parse java files and find the classes or interfaces which implement a particular interface. Hence I started with implementing custom rules in PMD. I was able to write an XPath expression to search the classes & interfaces but was not able to figure out the right way to pass the interface name for which the ...

Analyze source code with sonar

It is possible to take the source code directly from a svn repository and analyze it with sonar? Or configure sonar just to run a Checkstyle or pmd plugin for certain sources? I need to do this on non-maven projects. ...

Adding new java based PMD rule in eclipse pmd plugin..

How can we add a new java based pmd rule in eclipse pmd plugin? I am getting following error: Invalid Class implementation.The class must be in plugin classpath and implement the rule interface. I have extended rule class with AbstractRule class. ...

How to lock maven plugin version

How can I lock the version of a Maven plugin I want to use? I have the PMD plugin configured like so: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>2.5</version> <configuration> <outputDirectory>...

Add an empty string vs toString - why is it bad?

According to the tool PMD, the following is a bad practice: String s = "" + 123; // bad String t = Integer.toString(456); // ok This is an inefficient way to convert any type to a `String`. Why is it a bad thing to do? ...

How to export flexpmd results and warning in csv ,Xlx or txt file.

Hi i am new in flex, i installed command line flexpmd in my flexbuilder to improve my common coding mistake and for code optimization. when i run pmd it gives a lot of errors,warning , that's fine i want to export this result in a txt or csv file . please share u'r experience regarding this with explanation. ...

How to create PMD custom rule in ruleset?

I am damm confusing to create a new PMD rule in ruleset! can anyone guide me to the approach to do so? thanks in advance! ...

how to create rule for java comments in pmd?

Could someone please help me to create rule in pmd for eclipse? I am unable to start even i followed through PMD official site. I am planning to create rule in java instead of XPath rule. Any simple guidelines to start it? Thanks ...

pmd rule for checking java code for comments

i need a PMD java class for checking comments on java code. I am working on MyEclipse IDE. any idea? ...

need java pmd rule for comments in myeclipse

hello all, i am trying to write a java pmd rule to check source code comments. The rule should be able to identify all the method and variable declarations. If any method/variable declares without comment, the rule should give a warning as method/variable created without comments. any idea will be appreciated.......! ...