# Ratio red/green bar wrong

#### Details

• Type: Bug
• Status: Closed
• Priority: Major
• Resolution: Fixed
• Component/s:
• Labels:
None
• Similar Issues:

#### Description

The ratio M:C view on the red / green bar is wrong sometimes. Please check the calculation. See example attached

#### Attachments

1. bug2.png
311 kB

#### Activity

Marcel L created issue -
Hide
Ognjen Bubalo added a comment -

Hi,

I think we discussed this in this issue: https://issues.jenkins-ci.org/browse/JENKINS-16946

As I see it is alright except the alignment of the bars and when the Missed>Covered issue occurs, but this is not what I see on the picture.

Cheers,
Ogi

Show
Ognjen Bubalo added a comment - Hi, I think we discussed this in this issue: https://issues.jenkins-ci.org/browse/JENKINS-16946 As I see it is alright except the alignment of the bars and when the Missed>Covered issue occurs, but this is not what I see on the picture. Cheers, Ogi
Hide
Marcel L added a comment -

Hi Ogi,

could you the explain me the 2nd row ? In the first col I'say the ratio red/green is ~75/25 but it says 58%.
2nd row 2nd col is more obvious. It says 55 %, bute the red bar has 80% or 90% red.

Cheers,

Marcel

Show
Marcel L added a comment - Hi Ogi, could you the explain me the 2nd row ? In the first col I'say the ratio red/green is ~75/25 but it says 58%. 2nd row 2nd col is more obvious. It says 55 %, bute the red bar has 80% or 90% red. Cheers, Marcel
Hide
Ognjen Bubalo added a comment -

Hi Marcel,

The bar-s length is not connected to the coverage percent. The bar starts from the left. So if we check the second row second column:
The percent is 55% because (366/(366+298))*100. If 366 is the maximum length than the 298/366 is the red bar's length and 366 is the green bar's. The maximum length depends on other rows in that column. So lets say C: 366 is the biggest number of covered (I see only 2 rows), so other rows in that particular column have to be shorter. This is because we want to compare object's coverage with other objects. Check the 1st row. It is way shorter because it has only C:48.

Cheers,
Ogi

Show
Ognjen Bubalo added a comment - Hi Marcel, The bar-s length is not connected to the coverage percent. The bar starts from the left. So if we check the second row second column: The percent is 55% because (366/(366+298))*100. If 366 is the maximum length than the 298/366 is the red bar's length and 366 is the green bar's. The maximum length depends on other rows in that column. So lets say C: 366 is the biggest number of covered (I see only 2 rows), so other rows in that particular column have to be shorter. This is because we want to compare object's coverage with other objects. Check the 1st row. It is way shorter because it has only C:48. Cheers, Ogi
Hide
Marcel L added a comment -

Hi Ogi,

I understand the length of the bars depend the max coverages of each column. Ok that's fine.

Nevertheless the ratio of each red/green bar should represent the calculated percentage of the cell.

If you simply look at the 2nd row 2nd col, you could think. low coverage ,Close to 10%. But the percentage number gives you 55%.
This is non intuitive and wrong in my opinion. I'm not talking about the length of each red/green bar it's just about the ration red/green

Show
Marcel L added a comment - Hi Ogi, I understand the length of the bars depend the max coverages of each column. Ok that's fine. Nevertheless the ratio of each red/green bar should represent the calculated percentage of the cell. If you simply look at the 2nd row 2nd col, you could think. low coverage ,Close to 10%. But the percentage number gives you 55%. This is non intuitive and wrong in my opinion. I'm not talking about the length of each red/green bar it's just about the ration red/green
Hide
Ognjen Bubalo added a comment -

Hi,

"Nevertheless the ratio of each red/green bar should represent the calculated percentage of the cell."
No because the percentage does not tell us too much, but the length of missed and covered objects does.

Cheers,
Ogi

Show
Ognjen Bubalo added a comment - Hi, "Nevertheless the ratio of each red/green bar should represent the calculated percentage of the cell." No because the percentage does not tell us too much, but the length of missed and covered objects does. Check Marc's response in this thread: https://groups.google.com/d/msg/jenkins-jacoco-plugin-mailing-list/9pJCQpjEOck/X7Zo-MoLEw0J Cheers, Ogi
Hide
Marcel L added a comment -

Hi Ogi,

well the percentage does tell me something very important.
The percentage tells me I have 55% covered. Not more and not less. But If the graphical representation shows me 90% uncovered it's just wrong. And if the graphical respresentation of the percentage is wrong I don't see why I should use it.

I got Marc's and your point. The total length of the red/green bar gives me further informations. Comparing percentage between projects is not of much use. But I don't wan't to do that here.

I would like to use the red/green bar to quickly spot areas which should be improved.

Show
Marcel L added a comment - Hi Ogi, well the percentage does tell me something very important. The percentage tells me I have 55% covered. Not more and not less. But If the graphical representation shows me 90% uncovered it's just wrong. And if the graphical respresentation of the percentage is wrong I don't see why I should use it. I got Marc's and your point. The total length of the red/green bar gives me further informations. Comparing percentage between projects is not of much use. But I don't wan't to do that here. I would like to use the red/green bar to quickly spot areas which should be improved.
Hide
Laurent Schoelens added a comment -

Hello everyone,

I think the best solution would be to add an option for the plugin to set the graphical representation length of uncovered lines / covered lines.
By default we would keep this representation, and another option would be to set the length of graphical representation of M/C lines according to the M/(M+C) and C/(M+C) percentage.

Greetings,
Laurent

Show
Laurent Schoelens added a comment - Hello everyone, I think the best solution would be to add an option for the plugin to set the graphical representation length of uncovered lines / covered lines. By default we would keep this representation, and another option would be to set the length of graphical representation of M/C lines according to the M/(M+C) and C/(M+C) percentage. Greetings, Laurent
Hide
Marcus Bauer added a comment -

The representation is actually wrong, as the red bar had a size depending on Missed/Covered for percentages > 50%.

To pick up the previous example of 366 covered/298 missed, the length of the green bar should be 366+298 and 298 the red bar's length – relative to 100%.

The 100%-value should be based on the maximum covered+missed, not the maximum covered (or, maximum missed).

https://github.com/jenkinsci/jacoco-plugin/pull/30

Show
Marcus Bauer added a comment - The representation is actually wrong, as the red bar had a size depending on Missed/Covered for percentages > 50%. To pick up the previous example of 366 covered/298 missed, the length of the green bar should be 366+298 and 298 the red bar's length – relative to 100%. The 100%-value should be based on the maximum covered+missed, not the maximum covered (or, maximum missed). https://github.com/jenkinsci/jacoco-plugin/pull/30
Hide
Guido Grazioli added a comment -

My 2c: the report should reflect the same graphical representation generated by the jacoco site report, to avoid confusion.

https://github.com/jenkinsci/jacoco-plugin/pull/33

Show
Guido Grazioli added a comment - My 2c: the report should reflect the same graphical representation generated by the jacoco site report, to avoid confusion. https://github.com/jenkinsci/jacoco-plugin/pull/33
Hide

Code changed in jenkins
User: Marcus Bauer
Path:
src/main/java/hudson/plugins/jacoco/model/Coverage.java
src/main/java/hudson/plugins/jacoco/model/CoverageObject.java
http://jenkins-ci.org/commit/jacoco-plugin/571045f9f4a2eaabc83ee4009352f77bc0de05d9
Log:
JENKINS-17027 Red/green ratio is wrong

This issue is adressed by taking the total number of lines, etc. into account – instead of only the covered or missing items (depends on whether you have 50% coverage or more)

Show
SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marcus Bauer Path: src/main/java/hudson/plugins/jacoco/model/Coverage.java src/main/java/hudson/plugins/jacoco/model/CoverageObject.java http://jenkins-ci.org/commit/jacoco-plugin/571045f9f4a2eaabc83ee4009352f77bc0de05d9 Log: JENKINS-17027 Red/green ratio is wrong This issue is adressed by taking the total number of lines, etc. into account – instead of only the covered or missing items (depends on whether you have 50% coverage or more)
Hide

Code changed in jenkins
User: ognjenb
Path:
src/main/java/hudson/plugins/jacoco/model/Coverage.java
src/main/java/hudson/plugins/jacoco/model/CoverageObject.java
src/main/java/hudson/plugins/jacoco/report/CoverageReport.java
http://jenkins-ci.org/commit/jacoco-plugin/03bae7894d9b2a0c93c07a831534a39a7c84fb89
Log:
Merge pull request #30 from mabako/ratio

JENKINS-17027 Red/green ratio is wrong

Show
SCM/JIRA link daemon added a comment - Code changed in jenkins User: ognjenb Path: src/main/java/hudson/plugins/jacoco/model/Coverage.java src/main/java/hudson/plugins/jacoco/model/CoverageObject.java src/main/java/hudson/plugins/jacoco/report/CoverageReport.java http://jenkins-ci.org/commit/jacoco-plugin/03bae7894d9b2a0c93c07a831534a39a7c84fb89 Log: Merge pull request #30 from mabako/ratio JENKINS-17027 Red/green ratio is wrong Compare: https://github.com/jenkinsci/jacoco-plugin/compare/3a9f2f3d8483...03bae7894d9b
Hide

Should be fixed in jacoco-plugin 1.0.14

Show
centic added a comment - Should be fixed in jacoco-plugin 1.0.14
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
 Status Resolved [ 5 ] Closed [ 6 ]
R. Tyler Croy made changes -
 Workflow JNJira [ 147857 ] JNJira + In-Review [ 206461 ]
Hide

Code changed in jenkins
User: Marcus Bauer
Path:
src/main/java/hudson/plugins/jacoco/model/Coverage.java
src/main/java/hudson/plugins/jacoco/model/CoverageObject.java
Log:
JENKINS-17027 Red/green ratio is wrong

This issue is adressed by taking the total number of lines, etc. into account – instead of only the covered or missing items (depends on whether you have 50% coverage or more)

Show
SCM/JIRA link daemon added a comment - Code changed in jenkins User: Marcus Bauer Path: src/main/java/hudson/plugins/jacoco/model/Coverage.java src/main/java/hudson/plugins/jacoco/model/CoverageObject.java http://jenkins-ci.org/commit/jacoco-plugin/6adf351a1cef5438d98bf49d4dbc1c45a4b5ec1c Log: JENKINS-17027 Red/green ratio is wrong This issue is adressed by taking the total number of lines, etc. into account – instead of only the covered or missing items (depends on whether you have 50% coverage or more)

#### People

• Assignee:
Ognjen Bubalo
Reporter:
Marcel L