Skip to content

Prevent divisions by zero #128

Merged
merged 1 commit into from May 10, 2012

2 participants

@japgolly
japgolly commented May 4, 2012

There are a few cases where divisions by zero were possible.
When the happens the HTML reporter fails like this:

/home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/source_file.rb:171:in `round': NaN (FloatDomainError)
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/source_file.rb:171:in `round_float'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/source_file.rb:123:in `covered_strength'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/file_list.rb:42:in `block in covered_strength'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/file_list.rb:42:in `map'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/file_list.rb:42:in `covered_strength'
    from (erb):7:in `formatted_file_list'
    from /home/golly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/erb.rb:838:in `eval'
    from /home/golly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/erb.rb:838:in `result'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:53:in `formatted_file_list'
    from (erb):30:in `block in format'
    from /home/golly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/erb.rb:838:in `eval'
    from /home/golly/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/erb.rb:838:in `result'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:19:in `block in format'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:18:in `open'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:18:in `format'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/result.rb:90:in `format!'
    from /home/golly/projects/ruby_ext/.simplecov:32:in `block in <top (required)>'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/defaults.rb:51:in `call'
    from /home/golly/.rvm/gems/ruby-1.9.3-p125/bundler/gems/simplecov-8b3a937fe213/lib/simplecov/defaults.rb:51:in `block in <top (required)>'

Considered writing test cases for this but decided it's not worth it.
All existing tests pass with this fix.

@colszowka colszowka merged commit 8322eef into colszowka:master May 10, 2012
@colszowka
Owner

Merged, thanks for your effort!

@jperkin jperkin pushed a commit to joyent/pkgsrc that referenced this pull request Dec 9, 2013
taca Update ruby-simplecov to 0.6.4.
v0.6.4, 2012-05-10 ([changes](colszowka/simplecov@v0.6.3...v0.6.4))
-------------------

  * [BUGFIX] Encoding issues with ISO-8859-encoded source files fixed.
    See colszowka/simplecov#117. (thanks to @Deradon)
  * [BUGFIX] Ensure ZeroDivisionErrors won't occur when calculating the coverage result, which previously
    could happen in certain cases. See colszowka/simplecov#128. (thanks to @japgolly)
  * [REFACTORING] Changed a couple instance variable lookups so SimpleCov does not cause a lot of warnings when
    running ruby at a higher warning level. See colszowka/simplecov#106 and
    colszowka/simplecov#119. (thanks to @mvz and @gioele)


v0.6.3, 2012-05-10 ([changes](colszowka/simplecov@v0.6.2...v0.6.3))
-------------------

  * [BUGFIX] Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
    they are backwards-compatible with older multi_json gems in order to avoid simplecov polluting
    the multi_json minimum version requirement for entire applications.
    See colszowka/simplecov#132
  * Added appraisal gem to the test setup in order to run the test suite against both 1.0 and 1.3
    multi_json gems and ensure the above actually works :)
0410186
@jsonn jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Oct 11, 2014
taca Update ruby-simplecov to 0.6.4.
v0.6.4, 2012-05-10 ([changes](colszowka/simplecov@v0.6.3...v0.6.4))
-------------------

  * [BUGFIX] Encoding issues with ISO-8859-encoded source files fixed.
    See colszowka/simplecov#117. (thanks to @Deradon)
  * [BUGFIX] Ensure ZeroDivisionErrors won't occur when calculating the coverage result, which previously
    could happen in certain cases. See colszowka/simplecov#128. (thanks to @japgolly)
  * [REFACTORING] Changed a couple instance variable lookups so SimpleCov does not cause a lot of warnings when
    running ruby at a higher warning level. See colszowka/simplecov#106 and
    colszowka/simplecov#119. (thanks to @mvz and @gioele)


v0.6.3, 2012-05-10 ([changes](colszowka/simplecov@v0.6.2...v0.6.3))
-------------------

  * [BUGFIX] Modified the API-changes for newer multi_json versions introduced with #122 and v0.6.2 so
    they are backwards-compatible with older multi_json gems in order to avoid simplecov polluting
    the multi_json minimum version requirement for entire applications.
    See colszowka/simplecov#132
  * Added appraisal gem to the test setup in order to run the test suite against both 1.0 and 1.3
    multi_json gems and ensure the above actually works :)
93cae9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.