crossminer / scava

https://eclipse.org/scava/
Eclipse Public License 2.0
18 stars 13 forks source link

Metrics that measure percentages per day are wrong when zero data happen. #355

Closed creat89 closed 5 years ago

creat89 commented 5 years ago

After reading carefully issue #148, I have found that some factoids are affected by some transient metrics from OSSMETER that wrongly set a percentage of 14.29 (100/7) when the sum of data is zero. For example:

if (sumOfComments == 0)
        percentageOfComments = ( (float) 100 ) / 7;
    else
        percentageOfComments = ( (float) 100 * dayComments.getNumberOfComments() ) 

At the beginning I though that only one metric was concerned and fixed with commit https://github.com/crossminer/scava/commit/3a95498638d7164a9ecb99334c4bbf7d90672b58. However, I have found more metrics that need to be fixed.

The problematic code comes from OSSMETER and was barely checked in Scava as the metrics were supposedly to be correct. Thus, I'm analyzing each transient metric for code that looks similar and fix the issue in the transient metrics. Which should fix the factoids. As well, I'm adding methods to deal with these changes in the factoids.

creat89 commented 5 years ago

This issue should be fixed with commits:

https://github.com/crossminer/scava/commit/84b25a13d6cebac142df344b516246b8aece5b60

https://github.com/crossminer/scava/commit/a28468dfcdca5f0530291c5f6d957aad29a1b8b3