pmd

Checkstyle vs. PMD

We are introducing static analysis tools into the build system for our Java product. We are using Maven2 so Checkstyle and PMD integration come for free. However it looks like there is a large overlap in functionality between these two tools, in terms of enforcing basic style rules. Is there a benefit from utilizing both of these? I don...

Detect changing value of object passed as parameter

I'm now working with code that looks like this public String getName(User user) { user.setSth(...); return user.getName(); } I think it's bad practice to change objects passed as parameters. Is there a tool that detects that kind of code? I looked at findbugs, pmd and checkstyle, but could not find any check for this. P.S....

Do you know of pmd or checkstyle definition files that will enforce hibernate best practices?

For example, not to build queries by string manipulation, and the like. ...

Java PMD warning on non-transient class member

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

PMD rule DataflowAnomalyAnalysis oddness.

I have the following JUnit test: @Test public void testRunLocalhost() throws IOException, InterruptedException { // Start an AnnouncerThread final AnnouncerThread announcer = new AnnouncerThread(); announcer.start(); // Create the socket and listen on the right port. final DatagramSocket socket = new DatagramSocket(...

How do I enforce assigning to arguments of methods using FindBugs?

As an alternative to littering my code with thousands of final keywords in front of my parameters, I'm trying to enforce it using FindBugs. It doesn't seem possible to do this, but there should be a way, shouldn't there? Thanks ...

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

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 integration with IDEs (which, agai...

PMD rule for checking html/jsp files

Hi, I´d like to create a PMD rule that checks for a regex expression in any file (txt, html, jsp, etc.). The rule does not use Java or XPath structure. The idea is to read the file and add violations according to the line analyzed. I don´t know how to do this using Rule methods... Any idea? Thanks, Andre ...

Code analyzers: PMD & FindBugs

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

PMD - check for too many public methods (but exclude constructors and getters/setters)

I wish to add a PMD check to ensure that a class does not have too many public methods, but I do not want constructors and getters/setters to be included in the check. The ExcessivePublicCount check includes constructors, getters/setters and public variables, and I can't see a way to customise it. The TooManyMethods check excludes gett...

Simple, general-interest, code-analyzers based, Java questions

OK, after reviewing some code with PMD and FindBugs code analyzers, i was able to do great changes on the reviewed code. However, there are some things i don't know how to fix. I'll iterate them bellow, and (for better reference) i will give each question a number. Feel free to answer to any/all of them. Thanks for your patience. 1. Ev...

Best php qa tools

Hello, I am looking for qa tools for php. I am used to pmd, findbugs and checkstyle in the java world. Do you know some similar tools for php doing code analysis ? So far I have found but not tested yet : phplint pmd's cpd module PHP_CodeSniffer Thanks in advance for your help ...

Could someone explaining the reasoning behind some of these PMD rules?

DataflowAnomalyAnalysis: Found 'DD'-anomaly for variable 'variable' (lines 'n1'-'n2'). DataflowAnomalyAnalysis: Found 'DU'-anomaly for variable 'variable' (lines 'n1'-'n2'). DD and DU sound familiar...I want to say in things like testing and analysis relating to weakest pre and post conditions, but I don't remember the ...

Where will the result will be stored? after executing PMD

Hi I am using PMD to do code-review for my application. I am able to do the review, but i dont have a clue where the report will be stored. i am using this cmd "C:\PMD test\Source>java -jar pmd-4.2.5/lib/pmd-4.2.5.jar JavaSource\com\ex\app html basic" in command prompt. it is displaying the entire result in the command window, is there...

CPD / PMD between projects?

Hi all, I am rephrasing this question to make it a little more straightforward and easy to understand, hopefully. I have roughly 30 components (internal) that go into a single web application. That means 30 different projects with their own separate POM. I use inheritance quite a bit in my POMs so one of the things they inherit is a ...

Loose coupling : Can we use Interfaces when we need cloneables params ?

As I was advised by PMD, I want to reduce coopling by using interfaces instead of implementation ... In this case, knowing that I need a cloneable param, can I overcome the clone Dilemma (no clone() method in the Cloneable interface) ?? public MyConstructor(ArrayList<E> myParam) { this.myAttribute = (ArrayList<E>) myParam.clone(); ...

Can i customize PMD of my eclipse?

We know that PMD is integrated with eclipse. And i want to customize it. say suppose i want all variables to start with small letter or say i want all method name to be more than 8 characters or so on. is it possible to do that? And does anyone know what PMD stands for? ...

How to make maven-pmd-plugin support the latest PMD release?

http://maven.apache.org/plugins/maven-pmd-plugin/ is currently in version 2.4 which supports PMD version 4.2.2 Is it possible to use PMD version 4.2.5 with this plugin, if so how do we do this? ...

RegExp matching string not starting with my

For PMD I'd like to have a rule which warns me of those ugly variables which start with my. This means I have to accept all variables which do NOT start with my. So, I need a RegEx (re) which behaves as follows: re.match('myVar') == false re.match('manager') == true re.match('thisIsMyVar') == true re.match('myOtherVar') == f...

Custom PMD Rule - Check Package Comment In Place

I'm trying to write a rule to enforce that a package contains a Javadoc comment with a particular expression, e.g: /** * Example Expression */ Does anybody know how I would write such a rule using the AbstractJavaRule class. I've looked at ASTPackageDeclaration, but this doesn't appear to have what I want. Many thanks in advance.....