Skip to content
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

Merged
merged 4 commits into from
Oct 30, 2014
Merged

Fix crashes when source files are empty. #34

merged 4 commits into from
Oct 30, 2014

Conversation

jkrumow
Copy link
Collaborator

@jkrumow jkrumow commented Oct 27, 2014

Fixes issue #33.

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
Copy link
Contributor

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

Copy link
Collaborator Author

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

Copy link
Contributor

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

Copy link
Collaborator Author

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.

@marklarr
Copy link
Contributor

Thanks for this @tarbrain!

Julian Krumow added 3 commits October 29, 2014 01:17
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.
@jkrumow
Copy link
Collaborator Author

jkrumow commented Oct 30, 2014

Ok, I think this is it.
I have made some improvements and everything runs way more robust.
And looks much nicer too :-D

Cheers
tarbrain

@marklarr
Copy link
Contributor

Thanks!

marklarr added a commit that referenced this pull request Oct 30, 2014
Fix crashes when source files are empty.
@marklarr marklarr merged commit d7b833a into SlatherOrg:master Oct 30, 2014
@yas375
Copy link

yas375 commented Nov 2, 2014

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!

@marklarr
Copy link
Contributor

marklarr commented Nov 2, 2014

Sorry! I've been meaning to cut a new release, but I left my laptop at the
office this weekend

On Sunday, November 2, 2014, Victor Ilyukevich notifications@github.com
wrote:

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!


Reply to this email directly or view it on GitHub
#34 (comment).

@yas375
Copy link

yas375 commented Nov 2, 2014

@marklarr no worries! :)

@marklarr
Copy link
Contributor

marklarr commented Nov 3, 2014

1.5.1 is out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants