How to interpret Rails stats outputs table data?


How to interpret Rails stats?
enter image description here

What does the following columns means?

  • Lines
  • LOC
  • M/C
  • LOC/M


When looking at the output from rake stats, there are a few important bits of information that you should look at first, and that are all in the final summary line, in this case:

  • Lines of Code (Excluding test code): 337
  • Lines of Test Code: 406
  • Code to Test Ratio: 1:1.2

A Code to Test Ratio of 1:1.2 is pretty good.
For example, a Code to Test Ratio of 1 to 4 is somewhat ridiculous. Its incredibly high, and when you see something like this, its important to ask why? That’s pretty much the entire usefulness of the output of rake stats as a metric. Here are some -personal- guidelines:

  • Anything less than 1:1 the code probably lacks sufficient tests.
  • Anything more than 1:2 is suspect to questioning, but upon investigation could be found to be perfectly reasonable.

There are a few other nice things in the output from rake stats that are helpful for a birds eye view of the application. For example, I can tell that your application has 6 models and 5 controllers.

Hope that helped.