-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crashes when source files are empty. #34
Conversation
Check for nil more often. Updated specs and fixtures. Empty files also appear in cobertura xml report.
@@ -92,7 +96,11 @@ def num_lines_testable | |||
end | |||
|
|||
def rate_lines_tested | |||
(num_lines_tested / num_lines_testable.to_f) | |||
if num_lines_tested > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 divided by anything is always 0, so this diff doesn't functionally change anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, had to be:
if num_lines_testable > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you protecting against negative num_lines_tested
? Sounds like a bug if that were happening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I check num_lines_testable
against 0 to prevent division by zero.
Thanks for this @tarbrain! |
Correct and simplify code in rate_lines_tested and percentage_lines_tested. Method gcov_data returns an empty string instead of nil. Removed checks in nil where the empty string gets processed. Returning empty array for empty branch_coverage_data_for_statement_on_line values. Updated spec.
Ok, I think this is it. Cheers |
Thanks! |
Fix crashes when source files are empty.
Would be nice to have a new release of the gem with this fix included :) I've spend a few hours poking around today why it doesn't run to me before I've tried HEAD version of slather and it works! :) Thanks for fixing this! |
Sorry! I've been meaning to cut a new release, but I left my laptop at the On Sunday, November 2, 2014, Victor Ilyukevich notifications@github.com
|
@marklarr no worries! :) |
|
Fixes issue #33.