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

Merge all values of the hierarchy using max #27

Merged
merged 3 commits into from
Sep 21, 2023
Merged

Conversation

uhafner
Copy link
Member

@uhafner uhafner commented Jul 14, 2023

See jenkinsci/code-coverage-api-plugin#729

Tasks to do:

  • Replace add with max for inner nodes as well
  • Implement merging of package splitting

@uhafner uhafner added the bug Bugs or performance problems label Jul 14, 2023
if (hasChildren()) {
replaceValue(old.add(otherValue));
try {
var max = old.max(otherValue);
Copy link

Choose a reason for hiding this comment

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

With this functionality it's still a replace right? It just takes the coverage that's higer.
If there is a file with the functions a and b, coverage X covers func a and coverage Y covers function b, it's 50% overall coverage instead of 100% right?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is still not clear on how to merge inner nodes 😞

The code works for leaves but not for inner nodes yet. I can drop the details of inner nodes and compute them on my own but that will cause other problems...

Do you have an idea on how to implement this correctly? I do not see a solution for this problem.

Copy link

Choose a reason for hiding this comment

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

I don't have much experience with coverage reports, but by just looking at the cobertura one, I would expect that the lines should be merged (identified by number and branch) and hits > 0 should be preferred

Copy link
Member Author

Choose a reason for hiding this comment

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

After adding some more tests it looks that the merge using max is working correctly.

With this functionality it's still a replace right? It just takes the coverage that's higer.
If there is a file with the functions a and b, coverage X covers func a and coverage Y covers function b, it's 50% overall coverage instead of 100% right?

No, since each file has a coverage for X and Y. So X contains a=100% and b=0%, and Y contains a=0% and b=100%, then the max will produce a=100% and b=100%.

Copy link

Choose a reason for hiding this comment

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

I mean it's more correct than before.
Lets say we have function A.

function A(flag: boolean) {
  if(flag) {
    console.log('true');
  } else {
   console.log('false');
  }
}

If you have two separate coverage reports, one with the file x.spec.test that tests A only with true and one with the file y.spec.test that tests A only with false, then both of them would have the same coverage (about 50%) and the code-coverage-api would return 50% right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean it's more correct than before. Lets say we have function A.

function A(flag: boolean) {
  if(flag) {
    console.log('true');
  } else {
   console.log('false');
  }
}

If you have two separate coverage reports, one with the file x.spec.test that tests A only with true and one with the file y.spec.test that tests A only with false, then both of them would have the same coverage (about 50%) and the code-coverage-api would return 50% right?

No, the coverage is not measured per method, it is line based. The coverage per method is computed from the line coverage. So you should get a 100% coverage in total.

@uhafner uhafner marked this pull request as ready for review September 21, 2023 09:02
@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Merging #27 (9057752) into main (03bf2f9) will increase coverage by 0.05%.
The diff coverage is 88.88%.

@@             Coverage Diff              @@
##               main      #27      +/-   ##
============================================
+ Coverage     85.91%   85.96%   +0.05%     
  Complexity      492      492              
============================================
  Files            23       23              
  Lines          1356     1361       +5     
  Branches        194      193       -1     
============================================
+ Hits           1165     1170       +5     
+ Misses          145      144       -1     
- Partials         46       47       +1     
Files Changed Coverage Δ
.../main/java/edu/hm/hafner/coverage/PackageNode.java 100.00% <ø> (ø)
src/main/java/edu/hm/hafner/coverage/Node.java 82.38% <88.88%> (+0.51%) ⬆️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@uhafner uhafner merged commit 5d151ca into main Sep 21, 2023
30 checks passed
@uhafner uhafner deleted the merge-cobertura branch September 21, 2023 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs or performance problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants