From 27e4088732eb68a450322c7ef111b1592daff95b Mon Sep 17 00:00:00 2001 From: Porter Schutz Date: Mon, 29 Apr 2013 18:36:57 -0700 Subject: [PATCH] Handle case where there was zero coverage data. --- lib/simplecov-json.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/simplecov-json.rb b/lib/simplecov-json.rb index 4444f3c..67f376b 100644 --- a/lib/simplecov-json.rb +++ b/lib/simplecov-json.rb @@ -14,7 +14,7 @@ class SimpleCov::Formatter::JSONFormatter filename: sourceFile.filename, covered_percent: sourceFile.covered_percent, coverage: sourceFile.coverage, - covered_strength: sourceFile.covered_strength, + covered_strength: sourceFile.covered_strength.nan? ? 0.0 : sourceFile.covered_strength, covered_lines: sourceFile.covered_lines.count, lines_of_code: sourceFile.lines_of_code, } @@ -22,7 +22,7 @@ class SimpleCov::Formatter::JSONFormatter data[:groups] = result.groups data[:metrics] = { covered_percent: result.covered_percent, - covered_strength: result.covered_strength, + covered_strength: result.covered_strength.nan? ? 0.0 : result.covered_strength, covered_lines: result.covered_lines, total_lines: result.total_lines, }