Here are some handy plugins for Eclipse that I came across via an IBM Developerworks article by Paul Duvall.
CheckStyle: For coding standards
PMD's CPD: Enables discovering code duplication
Coverlipse: Measures code coverage
JDepend: Provides dependency analysis
Eclipse Metrics plugin: Effectively spots complexity
I have used the Checkstyle plugin for a few years now and found it extremely useful. In a nutshell, checkstyle will check your code against coding standards and issue a warning if you code something that is not in the correct format. This has always been a real bone of contention with fellow developers. One developer I worked with in the past felt that everyone should be free to code in whatever style they prefer. I would not agree with this at all. It can lead to code that is very hard to maintain and read.
With a plugin like Checkstyle you don't need "Code Police" checking the code and informing people that they are using the wrong style. If you want to push it one step further you can set up your automatic build (We used Cruisecontrol in the past) to mark a build as broken when it comes across a Checkstyle error. This ensures that a code base is readable and maintainable. Here is an example of bad coding style:
if (testBoolean) myNum++;
Many developers leave out the parenthesis as the compiler will not complain, this can often lead to confusion when you expect a line below to run when the statement is true but of course it won't because the myNum++ is going to run. The correct way to write this would be as follows:
if (testBoolean)
{
myNum++;
}
A new developer that comes across this code will know exactly what statement is run when the if statement is true. It is also possible to change the change the Checkstyle configuration for situations where a company has their own coding convention.
I have not used the other plugins yet but have a look at the article for how to install them. I am interested to see how good the code duplication plugin is. I hate when I come across "Cut and paste" coding because someone is too lazy to abstract the functionality into a base class.
#1 by Paul Browne - TIPE on January 12, 2007 - 12:14 pm
Stephen,
Good to see that you’re using coverlipse. We had a similar (open source) project called NoUnit on the go – still usable but Coverlipse probably has the edge (with Eclipse integration).
Paul
#2 by Stephen Downey on January 12, 2007 - 12:45 pm
Paul,
I haven’t tried Coverlipse yet, just came across it in the article above but it would be good to get a code coverage tool.
Have you stopped developing No-unit, if not would you try to build an Eclipse plugin for it? It would be a good way to get your tool to a lot of developers.
Stephen
#3 by Fred Coder on February 10, 2009 - 12:39 am
I think you need a better example… This statement:
if (testBoolean) myNum++;
is concise and clear as a bell. I can’t imagine anyone being confused as to whether the if statement applies to following code. The following code will NOT be indented, and neither is there an opening brace. (Its even more clear if you adopt a style that has opening braces always on the next line from an if/for/etc)
Putting in redundant braces simply clutters up the code and makes it harder to navigate through quickly.
#4 by Stephen Downey on February 10, 2009 - 10:28 pm
Hey “Fred Coder”,
Thanks for your feedback, I appreciate your view, however I would tend to disagree with you about redundant braces.
I think these are a necessity in coding and help to provide clean consistent code that can be easily picked up and followed.