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...
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....
For example, not to build queries by string manipulation, and the like.
...
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...
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(...
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
...
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...
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
...
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...
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...
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...
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
...
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 ...
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...
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 ...
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();
...
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?
...
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?
...
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...
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.....