Ruby Static Analysis Tools Roundup: metric_fu, Simian, Saikuro and More
Code quality is one of the bricks of software quality. While tools for the mainstream languages such as Java and C++ have reached a certain maturity, tools for Ruby are still growing. And they might be needed more and more as Ruby's usage spreads from early adopters to the early majority, and SLOC (Source Lines Of Code) continues to rise. Automatic tools can be used to detect several types of problems including inconsistent style, long methods and repeated code.
Steve Hayes gave a presentation entitled "Code Quality For Java And Ruby" at the Agile2009 Conference held in Chicago, which gives InfoQ a good opportunity to review the tools available in the Ruby world:
- Roodi (Ruby Object Oriented Design Inferometer) - this parses your Ruby code and warns you about design issues from the list you configured, ie: Class line count check, for loop check, parameter number check, cyclomatic checks and 10 other checks
- Reek - similar in concept to Roodi
- Saikuro - designed to check cyclomatic complexity
- Flog - created by Ryan Davis, this computes a score of your code: the higher the score is, the worse your code is. ABC metrics (Assignments, Branches and Calls) are taken into account to compute the score
- Simian - a similarity analyser, this can be used for duplication identification (you need a $99 license for commercial use)
- Flay - this is another free tool from Ryan Davis that finds structural similarities in code
Using all these tools can quickly become a pain, that's when metric_fu comes to the rescue. It includes all the mentioned tools (except Simian), and can easily generate a report about your application. It integrates easily with Rails and generates graphs over time.
Graph from Jakes Scruggs
You can follow Assaf Arkin's Guide to setting up Hudson for a Rails project with metric_fu support.
Railscast #166 on metric_fu
Thank you both for your links.
Marco, I also found out afterward this one for Rails: github.com/felipegiotto/Inotegration
duplicate lines report
Ralph Winzinger Nov 25, 2014