SourceMonitor has a bug for "code complexity" metric in minefield.java

Greetings,

There is a metric that SourceMonitor miss-calculates for one file: minefield.java. It is a known bug that was reported last year and did not get fixed yet. I activated this bug when I tweaked the minefield.java code, so that I provide sub-optimal code for you to analyse.

There is an easy fix for it: the problem is the two for-loops in the constructor. SourceMonitor only counts 1 method in the class and the complexity is zero. Solution: extract the loops in a separate method called "private void initMap()" and SM will give the correct metrics.

 Thank you Karl Thomas for the proposed fix - it is correct.

 

Published Mar. 8, 2016 4:07 PM - Last modified Mar. 9, 2016 9:44 AM