Monday, July 14, 2008

Detecting Code Smells With Eclipse and CheckStyle

In a new article "Automation for the people: Continual refactoring" as a part of the "Automation for the people" series, Paul Duvall discusses the use of static code analysis tools to identify code smells and suggested refactorings. The article shows how to

Reduce conditional complexity code smells by measuring cyclomatic complexity using CheckStyle and providing refactorings such as Replace Conditional with Polymorphism

Remove duplicated code code smells by assessing code duplication using CheckStyle and providing refactorings such as Pull Up Method

Thin large class code smells by counting source lines of code using PMD (or JavaNCSS) and providing refactorings such as Extract Method

Wipe out too many imports code smells by determining a class's efferent coupling using CheckStyle (or JDepend) and providing refactorings such as Move Method

There's MoreThe following is a short list of static code analysis tools available for Java