Skip to content

Fix calculation of branch coverage when a class has no branches.#40

Merged
marklarr merged 5 commits intoSlatherOrg:masterfrom
jkrumow:master
Dec 9, 2014
Merged

Fix calculation of branch coverage when a class has no branches.#40
marklarr merged 5 commits intoSlatherOrg:masterfrom
jkrumow:master

Conversation

@jkrumow
Copy link
Collaborator

@jkrumow jkrumow commented Nov 15, 2014

Branch-rate should be 1.0 when a class has no branches since there is only one code path which can be taken.

Something I have noticed lately.

Cheers
tarbrain

@marklarr
Copy link
Contributor

Thanks @tarbrain! I'll have a look at this soon.

@jkrumow
Copy link
Collaborator Author

jkrumow commented Nov 19, 2014

According to Cobertura's metrics and implementation a file without lines / branches will have a rate of 1.0 (100%):

https://github.com/cobertura/cobertura/blob/master/cobertura/src/main/java/net/sourceforge/cobertura/coveragedata/CoverageDataContainer.java (lines 115 , 160)

https://github.com/cobertura/cobertura/blob/master/cobertura/src/main/java/net/sourceforge/cobertura/coveragedata/ClassData.java (lines 164, 220)

I've made the changes only in slather/coverage_service/cobertura_xml_output.rb so coverage_file.rb remains unaffected.

CHANGELOG.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gem's current version is 1.5.3, I think we want to move these changes to the next release?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@marklarr
Copy link
Contributor

marklarr commented Dec 7, 2014

Cool! Sorry for the wait, @tarbrain

marklarr added a commit that referenced this pull request Dec 9, 2014
Fix calculation of branch coverage when a class has no branches.
@marklarr marklarr merged commit fbd611f into SlatherOrg:master Dec 9, 2014
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.

2 participants