From fe29f291d5a2d44bac8dc2f7bbb32d86b930d126 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 17 Mar 2017 20:13:35 +0100 Subject: [PATCH] Try at fixing FloatDomainError more closely restoring origin version * Fixes #563 hopefully * tracked the bug back to hopefully b35f569fdb79f1175 (only thing that touched the caller of the method, but maybe there is some other interaction ongoing) * Guess is/was that this might trigger if there aren't any lines covered... obviously test cases still missing to up our coverage here :) --- lib/simplecov/source_file.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/simplecov/source_file.rb b/lib/simplecov/source_file.rb index c014f8ab..23deb247 100644 --- a/lib/simplecov/source_file.rb +++ b/lib/simplecov/source_file.rb @@ -127,11 +127,16 @@ def covered_percent def covered_strength return 0.0 if no_lines? - round_float(lines_strength / relevant_lines.to_f, 1) + effective_lines_count = Float(relevant_lines) + if effective_lines_count.zero? + 0.0 + else + round_float(lines_strength / effective_lines_count, 1) + end end def no_lines? - lines.length.zero? || lines.length == never_lines.size + lines.length.zero? || (lines.length == never_lines.size) end def lines_strength