Questions tagged [pmd]

PMD scans source code and looks for potential problems like possible bugs, dead code, suboptimal code, overcomplicated expressions, and duplicate code. PMD supports Java, JavaScript, XML, and many more.

PMD scans source code and looks for potential problems like possible bugs, dead code, suboptimal code, overcomplicated expressions, and .

857 questions
7
votes
4 answers

Why shouldn't all function arguments be declared final?

Ok, so I understand why we should declare an argument to be final from this question, but I don't understand why we shouldn't... Since Java always uses pass by value, this means that we can't return a new value through the given argument, we can…
Vlad Ilie
  • 1,389
  • 1
  • 13
  • 37
7
votes
2 answers

PMD in eclipse does not accept exclude-pattern

I am using PMD under eclipse 4.3.1 / Kepler and I cannot exclude files and folders from the violation check. My folder…
hkais
  • 338
  • 4
  • 15
7
votes
4 answers

Not able to install PMD in Eclipse Kepler

I have installed PMD in Eclipse Kepler using Eclipse market place. But I am unable to access it after the installation. When I go to Window → Preferences and search for PMD, I get no results. Is there any other plugin available for source code…
user223614
  • 303
  • 1
  • 6
  • 15
7
votes
1 answer

Best practice to keep method visibility with Spring @Controller stereotype

My project at current job use private access modifier for methods of MVC controllers: @Controller public class HelloWorldController { @RequestMapping("/helloWorld") private ModelAndView helloWorld() { I have integrated PMD and his report…
gavenkoa
  • 45,285
  • 19
  • 251
  • 303
7
votes
2 answers

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.…
hypercube
  • 958
  • 2
  • 16
  • 34
7
votes
6 answers

Eclipse PMD Can't find basic.xml

When attempting to run pmd for a project in Eclipse/Juno, I am getting this error. An internal error occurred during: "ReviewCode". Couldn't find the class Can't find resource rulesets/basic.xml. Make sure the resource is a valid file or URL or…
Karl
  • 221
  • 2
  • 5
  • 12
7
votes
2 answers

How to get InetAddress with wildcard ip 0.0.0.0?

InetAddress doesn't provide any static method or constructor to get InetAddress with wildcard IP 0.0.0.0 . The only way is InetAddress.getByName("0.0.0.0") But PMD gives AvoidUsingHardCodedIP if we pass hard coded IP. Is there any way to get…
anupsth
  • 657
  • 1
  • 6
  • 18
7
votes
2 answers

Any open-source software that is similar to Fortify?

I have been using PMD and Findbug for my application but fortify managed to detect some of the security vulnerabilities in my application. I am wondering if there is other open-source software that does the similar job as Fortify?
jj pan
  • 287
  • 2
  • 5
  • 17
7
votes
2 answers

Which static analysis tool to use for scanning data flow from one method to another?

Say there are two methods in my library: void com.somepackage.SomeClass.someSink(String s) and int com.someotherpackage.SomeOtherClass.someSource(int i) The first method is used as a data sink, while the second as a data source in my code. The type…
Jus12
  • 17,824
  • 28
  • 99
  • 157
6
votes
3 answers

java :Why the Local variable should be declared final

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…
user663724
6
votes
3 answers

Do you know of PMD or Checkstyle rules that will enforce hibernate best practices?

For example, not to build queries by string manipulation, and the like.
flybywire
  • 261,858
  • 191
  • 397
  • 503
6
votes
1 answer

Why a PMD violation for unused method when it is obviously used

PMD Failure: ... Rule:UnusedPrivateMethod Priority:3 Avoid unused private methods such as 'printMyString(String)' private void anyMethod() { var myString = "a String"; printMyString(myString); } private void printMyString(String string) { …
fedup
  • 1,209
  • 11
  • 26
6
votes
2 answers

Ignore PMD rule for methods with a Test annotation

I use PMD for a Spring Boot project which contains MockMvc tests. The class enforces the user to catch the general Exception. class MockMvc { public ResultActions perform(RequestBuilder requestBuilder) throws Exception {} } The usage leads to a…
sschmeck
  • 7,233
  • 4
  • 40
  • 67
6
votes
2 answers

Eclipse / SonarQube Integration: How to handle Checkstyle / PMD / FindBugs

If I work with Eclipse and want to use SonarQube as single source of code rules, I understand I need to use the SonarLint plugin. However, SonarLint will only check squid rules, no Checkstyle/PMD/Findbugs rules (although they can be used in…
Jörn
  • 171
  • 1
  • 11
6
votes
2 answers

Should I split methods for reuse in JUnit?

I have the following JUnit test. The method that I'm testing is quite simple, it just receives a number and returns a List with its divisors. I don't want to repeat the test code many times, so I've created an auxiliar method,…
AJPerez
  • 3,435
  • 10
  • 61
  • 91