views:

1151

answers:

8

Which plugins for Eclipse do you recommended for analyzing your code?

Bug finding, unused code detection, suggested refactoring, ...

+8  A: 

Findbugs.

Milhous
+6  A: 

PMD can also provide a lot of useful data about:

  • Possible bugs - empty try/catch/finally/switch statements
  • Dead code - unused local variables, parameters and private methods
  • Suboptimal code - wasteful String/StringBuffer usage
  • Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
  • Duplicate code - copied/pasted code means copied/pasted bugs

Used in combination with checkstyle, you can enforce consistent code style with refactoring suggestions.

VonC
+1  A: 

FindBugs, Checkstyle, PMD

Ken Liu
+6  A: 

Don' t miss the Java compiler options (Window->Preferences->Java->Compiler->Error/Warnings) that come out-of-the-box with Eclipse itself. Raising each option as strict as your current project can tolerate will give you great benefit without having install any additional plugin. I use it in combination with Findbugs, both running automatically.

Also out-of-the-box comes CodeStyle options (Window->Preferences->Java->CodeStyle *) that you can fine tune to your and/or your organisation standard. Do a really great job, combine with Window->Preferences->Java->Editor->Save Actions -> Format source code checked.

Olivier
Good points. Eclipse is more and more complete on that front. +1
VonC
+3  A: 

I sometimes find it handy to see quick code coverage by using EclEmma to run my JUnit tests. EclEmma is an Emma (code coverage tool) plugin for Eclipse. It instruments your code at runtime, so there is only one step - run your tests from within Eclipse.

It's sweet having coverage-highlighted source files in your Eclipse editor window, so you can verify your coverage while you write new code and corresponding unit tests to see what you may have missed testing. See the first link for screenshots.

Joshua McKinnon
A: 

slightly different analysis output crap4j

Craig Angus
A: 

Hm, the Code Analysis Plugin (CAP) hasn't been mentioned yet. Here are some screenshots and features from their website:

Helps to improve

* Encapsulation
* Architecture
* Package structure
* (Re)usability
* Maintainability
moxn
A: 

There is a list here: http://www.eclipse-plugins.info/eclipse/plugins.jsp?category=Source+Code+Analyzer which lists recommended an popular code analysis tools. Unfortunately the site seems not to be updated lately.

cuh