Code Metrics Calculation in Visual Studio

The theoretically optimal values are: Maintainability index: 100. Higher values indicate better maintainability. Cyclomatic complexity: 1. The number of different paths that code can take. Depth of inheritance: 1. The number of class definitions above this one in the inheritance tree, not including interfaces. Class coupling: 0. Number of other entities this entity is dependent … Read more

Do you find cyclomatic complexity a useful measure?

We refactor mercilessly, and use Cyclomatic complexity as one of the metrics that gets code on our ‘hit list’. 1-6 we don’t flag for complexity (although it could get questioned for other reasons), 7-9 is questionable, and any method over 10 is assumed to be bad unless proven otherwise. The worst we’ve seen was 87 … Read more

What is meant by ‘Assignment Branch Condition Size too high’ and how to fix it?

Assignment Branch Condition (ABC) size is a measurement of the size of a method. It is essentially determined by counting the number of Assignments, Branches, and Conditional statements. (more detail..) To reduce ABC score, you could move some of those assignments into before_action calls: before_action :fetch_current_category, only: [:show,:edit,:update] before_action :fetch_categories, only: [:show,:edit,:update] before_action :fetch_search_results, only: … Read more

What is a reasonable code coverage % for unit tests (and why)? [closed]

This prose by Alberto Savoia answers precisely that question (in a nicely entertaining manner at that!): http://www.artima.com/forums/flat.jsp?forum=106&thread=204677 Testivus On Test Coverage Early one morning, a programmer asked the great master: “I am ready to write some unit tests. What code coverage should I aim for?” The great master replied: “Don’t worry about coverage, just write … Read more

tech