Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Code Analysis Tool [duplicate]

Possible Duplicate:
Static Analysis tool recommendation for Java?

I have to find a java code analysis or inspection tool which can customized with user defined rule. Actually, I have to make some static code in my workspace to non-static. a tool where i can write some rules like if such a code is encountered in entire workspace then do something.

Can anyone suggest something.

like image 637
Vikas Sharma Avatar asked Mar 07 '12 06:03

Vikas Sharma


People also ask

How do I fix duplicates in Java?

If a duplicate code is present in: The same method, create the same Local Variable and reuse it. The same class, create common Method refactoring. Subclasses of the same hierarchy, you should Extract Method and Pull it Up. Two different classes, you can use objects.

What is Java duplication code?

Simply put, it's when a snippet of code appears multiple times throughout a codebase. It happens for many reasons: Somebody wanted to reuse a function in a different class, and copy-paste was the quickest solution.

How do I find duplicate lines in SonarQube?

SonarQube shows you all the duplications metrics on a project, package, or class basis. Further, you can use the Duplications tab in the file detail view to see the location of a duplication in a class.


2 Answers

You can use

  1. Google CodePro Analytix (Free)(one of my favourate tool),

  2. SpotBugs (formerly known as Findbugs)

  3. PMD

  4. Checkstyle

  5. Sonar - It's also good because it integrates all Findbugs, PMD, Checkstyle in one place and very well dashboard reporting available

like image 93
arshwarsi Avatar answered Oct 16 '22 10:10

arshwarsi


PMD is extensible. The rules are file based and can be coded either in Java or XPath.

like image 3
Andreas Dolk Avatar answered Oct 16 '22 10:10

Andreas Dolk