diff --git a/teamcity-clover.php b/teamcity-clover.php index fd9823e..9ea2037 100644 --- a/teamcity-clover.php +++ b/teamcity-clover.php @@ -50,10 +50,10 @@ 'CodeCoverageAbsMCovered' => (int) $metrics['coveredmethods'], 'CodeCoverageAbsCTotal' => (int) $metrics['classes'], 'CodeCoverageAbsCCovered' => $coveredClasses, - 'CodeCoverageB' => $metrics['coveredstatements'] / $metrics['statements'] * 100, - 'CodeCoverageL' => $metrics['coveredelements'] / $metrics['elements'] * 100, - 'CodeCoverageM' => $metrics['coveredmethods'] / $metrics['methods'] * 100, - 'CodeCoverageC' => $coveredClasses / $metrics['classes'] * 100, + 'CodeCoverageB' => $metrics['statements'] ? ($metrics['coveredstatements'] / $metrics['statements'] * 100) : 0, + 'CodeCoverageL' => $metrics['elements'] ? ($metrics['coveredelements'] / $metrics['elements'] * 100) : 0, + 'CodeCoverageM' => $metrics['methods'] ? ($metrics['coveredmethods'] / $metrics['methods'] * 100) : 0, + 'CodeCoverageC' => $metrics['classes'] ? ($coveredClasses / $metrics['classes'] * 100) : 0, 'Files' => (int) $metrics['files'], 'LinesOfCode' => (int) $metrics['loc'], 'NonCommentLinesOfCode' => (int) $metrics['ncloc'],