Skip to content

Commit

Permalink
Check if Cobertura line-rate and branch-rate are valid.
Browse files Browse the repository at this point in the history
  • Loading branch information
grigaci committed May 8, 2016
1 parent 3e65af3 commit 5af4f2f
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ public float get(String coberturaFilePath) {
String content = FileUtils.readFileToString(new File(coberturaFilePath));
float lineRate = Float.parseFloat(find(content, "line-rate=\"([0-9.]+)\""));
float branchRate = Float.parseFloat(find(content, "branch-rate=\"([0-9.]+)\""));
return (lineRate / 2 + branchRate / 2);
float linesValid = Float.parseFloat(find(content, "lines-valid=\"([0-9.]+)\""));
float branchesValid = Float.parseFloat(find(content, "branches-valid=\"([0-9.]+)\""));
if (linesValid > 0 && branchesValid > 0) {
return (lineRate / 2 + branchRate / 2);
} else if (linesValid > 0) {
return lineRate;
} else if (branchesValid > 0) {
return branchRate;
} else {
return 0;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 5af4f2f

Please sign in to comment.