I empathise with your tales of woe, but I think you go too far in dismissing the value of metrics as source code instrumentation.
If one considers a given metric to be part of the whole picture, but at the same time does not confuse the single metric for the whole of the picture, I think metrics can help a great deal, particularly when dealing with large volumes of code, and large numbers of coders, and particularly in terms of informing decisions about where to spend code review and unit test effort.
It sounds like you have suffered from idiotic applications of misguided rules more than you have suffered from the metrics themselves, but perhaps that is the price of their existence; that they will be abused like so much else.
Out of interest, I generated these metrics for a part of my hobby chess engine -
| Method | Cyc. Compl. | LOC | Blank lines | Comment lines | Comment % | Statements |
|---|---|---|---|---|---|---|
| GenMoves | 50 | 437 | 23 | 114 | 26.09 | 236 |
| FENToPosition | 41 | 117 | 18 | 27 | 23.08 | 99 |
| IsAttacked | 26 | 193 | 17 | 74 | 38.34 | 102 |
| PieceToString | 16 | 21 | 0 | 0 | 0.00 | 32 |
| ColourOfPiece | 14 | 16 | 4 | 0 | 0.00 | 4 |
| PieceToString | 10 | 15 | 0 | 0 | 0.00 | 20 |
| HitTheEdge | 10 | 31 | 9 | 0 | 0.00 | 10 |
| ASCToFEN | 9 | 53 | 6 | 19 | 35.85 | 26 |
| FirstBit | 8 | 39 | 10 | 0 | 0.00 | 21 |
| MoveToString | 8 | 28 | 1 | 0 | 0.00 | 17 |
| Slide | 5 | 25 | 6 | 4 | 16.00 | 15 |
| GetMoveCount | 4 | 21 | 6 | 0 | 0.00 | 12 |
| PrintMoveList | 2 | 5 | 0 | 0 | 0.00 | 2 |
| LeftEdge | 1 | 4 | 0 | 0 | 0.00 | 2 |
| RightEdge | 1 | 3 | 0 | 0 | 0.00 | 1 |
| TopEdge | 1 | 3 | 0 | 0 | 0.00 | 1 |
| BottomEdge | 1 | 3 | 0 | 0 | 0.00 | 1 |
| SquareToString | 1 | 3 | 0 | 0 | 0.00 | 1 |
| SquareToString | 1 | 3 | 0 | 0 | 0.00 | 1 |
| SquareToRank | 1 | 3 | 0 | 0 | 0.00 | 1 |
| SquareToFile | 1 | 3 | 0 | 0 | 0.00 | 1 |
| ASCToPosition | 1 | 3 | 0 | 0 | 0.00 | 1 |
| Warn | 1 | 3 | 0 | 0 | 0.00 | 1 |
As a profile of this part of the engine, I found this very interesting. For instance,
Now some of these thoughts I could have had by simply browsing the code, but I hope I'm illustrating the usefulness of these metrics as a high-level view. I find them provocative in a highly beneficial way.
In reply to Re^2: Cyclomatic Complexity of Perl code
by EdwardG
in thread Cyclomatic Complexity of Perl code
by ryanus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |