code_metrics
code_metrics copied to clipboard
"Test LOC" is always 0
The value for "Test LOC" always seems to be zero.
The bug seems to have been introduced by commit https://github.com/bf4/code_metrics/commit/e017a71ebe05bd837564d85879429accfb1f8a94
Apparently the TEST_TYPES array in lib/code_metrics/statistics.rb is always empty, which means that the Array#include? check in CodeMetrics::Statistics#calculate_tests always fails.
Here is code_metrics (version 0.1.3) output:
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 772 | 596 | 12 | 59 | 4 | 8 |
| Helpers | 52 | 45 | 0 | 6 | 0 | 5 |
| Models | 190 | 147 | 8 | 15 | 1 | 7 |
| Mailers | 0 | 0 | 0 | 0 | 0 | 0 |
| Javascripts | 209 | 168 | 0 | 36 | 0 | 2 |
| Libraries | 0 | 0 | 0 | 0 | 0 | 0 |
| Controller tests | 174 | 86 | 9 | 0 | 0 | 0 |
| Helper tests | 0 | 0 | 0 | 0 | 0 | 0 |
| Model tests | 49 | 21 | 7 | 0 | 0 | 0 |
| Mailer tests | 0 | 0 | 0 | 0 | 0 | 0 |
| Integration tests | 0 | 0 | 0 | 0 | 0 | 0 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total | 1446 | 1063 | 36 | 116 | 3 | 7 |
+----------------------+-------+-------+---------+---------+-----+-------+
Code LOC: 1063 Test LOC: 0 Code to Test Ratio: 1:0.0
And here is rake stats (Rails version 4.2.3, rake version 10.4.2) for the same project:
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 772 | 596 | 12 | 59 | 4 | 8 |
| Helpers | 52 | 45 | 0 | 6 | 0 | 5 |
| Models | 190 | 147 | 8 | 15 | 1 | 7 |
| Mailers | 0 | 0 | 0 | 0 | 0 | 0 |
| Javascripts | 209 | 168 | 0 | 36 | 0 | 2 |
| Libraries | 0 | 0 | 0 | 0 | 0 | 0 |
| Controller tests | 174 | 86 | 9 | 0 | 0 | 0 |
| Helper tests | 0 | 0 | 0 | 0 | 0 | 0 |
| Model tests | 49 | 21 | 7 | 0 | 0 | 0 |
| Mailer tests | 0 | 0 | 0 | 0 | 0 | 0 |
| Integration tests | 0 | 0 | 0 | 0 | 0 | 0 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total | 1446 | 1063 | 36 | 116 | 3 | 7 |
+----------------------+-------+-------+---------+---------+-----+-------+
Code LOC: 956 Test LOC: 107 Code to Test Ratio: 1:0.1
Oh, that's no good. Care to make a PR to fix it?
Sure. See https://github.com/bf4/code_metrics/pull/13