Rails stats

185 views

In Ruby on Rails, the rake task in charge of generating a code statistics report of your application is ____.

The correct answer is

rake code

rake statistics

rake stats

Unlock Your Ruby Potential

Subscribe to RubyCademy and get free access to all our courses, plus hundreds of fun Ruby cards, quizzes, guides, and tutorials!

Explanation

If you're new to it, running the command rake stats provides a brief overview, summarizing details such as lines of code, lines of test code, class count, method count, the ratio of methods to classes, and the ratio of lines of code per method.

When reviewing the results generated by rake stats, the crucial information to focus on initially is encapsulated in the final summary line, as exemplified below:

  • Lines of Code (Excluding test code)
  • Lines of Test Code
  • Code to Test Ratio

A Code to Test Ratio of 1 to 3 is notably high, prompting the question: why? This disproportion raises concerns about the adequacy of testing. In essence, the utility of 'rake stats' lies in serving as a metric to prompt further inquiry. Drawing from observations of well-tested and poorly tested applications, the following guidelines have been formulated:

If the Code to Test Ratio is below 1:1, the code likely lacks adequate tests.
Ratios exceeding 1:2 are subject to scrutiny, but further investigation may reveal a valid rationale.

Unlock Your Ruby Potential

Subscribe to RubyCademy and get free access to all our courses, plus hundreds of fun Ruby cards, quizzes, guides, and tutorials!

RubyCademy ©