Commit fcf6cedb authored by Rusty Russell's avatar Rusty Russell

ccanlint: give a bonus for 100% code coverage

parent ab3df365
...@@ -32,12 +32,16 @@ static bool find_source_file(const struct manifest *m, const char *filename) ...@@ -32,12 +32,16 @@ static bool find_source_file(const struct manifest *m, const char *filename)
return false; return false;
} }
/* 1 point for 50%, 2 points for 75%, 3 points for 87.5%... */ /* 1 point for 50%, 2 points for 75%, 3 points for 87.5%... Bonus for 100%. */
static unsigned int score_coverage(float covered, unsigned total) static unsigned int score_coverage(float covered, unsigned total)
{ {
float thresh, uncovered = 1.0 - covered; float thresh, uncovered = 1.0 - covered;
unsigned int i; unsigned int i;
if (covered == 1.0)
return total;
total--;
for (i = 0, thresh = 0.5; i < total; i++, thresh /= 2) { for (i = 0, thresh = 0.5; i < total; i++, thresh /= 2) {
if (uncovered > thresh) if (uncovered > thresh)
break; break;
...@@ -112,7 +116,7 @@ static void analyze_coverage(struct manifest *m, bool full_gcov, ...@@ -112,7 +116,7 @@ static void analyze_coverage(struct manifest *m, bool full_gcov,
if (total_lines == 0) if (total_lines == 0)
score->total = score->score = 0; score->total = score->score = 0;
else { else {
score->total = 5; score->total = 6;
score->score = score_coverage(covered_lines / total_lines, score->score = score_coverage(covered_lines / total_lines,
score->total); score->total);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment