Please enter name
please enter valid email
please enter comment
Please enter correct code

Static code analysis in Ruby

Contributed by Khurshidali Shaikh on 4 Jul 2011

Static code analysis in Ruby can be done using metric_fu. metric_fu is a nice gem which internally uses Saikuro, Flog, Flay, Rcov, Reek, Roodi, Churn, RailsBestPractices and generals useful quality metrics about the code. With the help of above it analyzes code for complexity, convention compliance, duplicate and unused code.

Saikuro

Saikuro analyzes code and reports cyclomatic complexity of each method in the analyzed code. Each method has a complexity of 1 by default. In addition Saikuro adds 1 to the cyclomatic complexity for each of the below :

Flog

Flog scores an ABC(Assignment, Branches, Conditions) metric on the methods. With the help of this classes that have a high average flog score may be further looked at for optimization and refactoring.

Flay

Flay analyzes code for structural similarities. Code reported by Flay is a good candidate for refactoring.

Rcov

Rcov is a code coverage tool. It analyses the code coverage by running the unit tests in the project.

Reek

Reek reports code smells in the ruby code. Some of the code smells its reports are missing comments, long methods, long class, long parameter list, uncommunicative names, etc. A complete list of code smells reported by Reek cane be found here - https://github.com/kevinrutherford/reek/wiki/code-smells

Roodi

Roodi stands for Ruby Object Oriented Design Inferometer. It parses your Ruby code and warns you about design issues you have based on the checks that is has configured. Follwing checks are the supported checks. A yml file can be provided to include only selected checks

Churn

Gives a number of times a file, class, method has been changed during the life of the project. Churn evaluates this by looking at the commits done in the SCM repository. Chrun supports Git, Mercurial and SVN (partially)

Rails Best Practices

Analyses code for Rails Best Practices. The default supported checks are here https://github.com/flyerhzm/rails_best_practices/wiki

Other Tools

There are some other tools that may also be useful

Visit us at Neevtech.com to know more about our offerings.

Tags: , , , , , , , , , ,

2 Comments

  1. fas8ohion says:

    9…

    This article is really dulcet, a friend gave me a look. I catched sight of, I would like to express the feelings I looked. Others did not feel that I do not mind, at least now I convey myself….

  2. blog0blogs says:

    1…

    Have a good day!I’m very glad when see your post.I quite approve of your point of view.I will continue to notice on your blog.I sure that the future I will see more about your wonderful views….

Leave a Comment

Security Code: