jenkinsci / code-coverage-api-plugin

Deprecated Jenkins Code Coverage Plugin
https://plugins.jenkins.io/code-coverage-api/
MIT License
111 stars 77 forks source link

Add a new option to ignore parser errors #788

Closed uhafner closed 10 months ago

uhafner commented 10 months ago

For more details, please see https://github.com/jenkinsci/coverage-model/pull/39.

Fixes https://github.com/jenkinsci/code-coverage-api-plugin/issues/785

codecov[bot] commented 10 months ago

Codecov Report

Merging #788 (8106422) into master (2ef24aa) will increase coverage by 0.06%. Report is 2 commits behind head on master. The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #788      +/-   ##
============================================
+ Coverage     74.08%   74.14%   +0.06%     
- Complexity     1698     1705       +7     
============================================
  Files           130      130              
  Lines          6289     6301      +12     
  Branches        677      677              
============================================
+ Hits           4659     4672      +13     
  Misses         1407     1407              
+ Partials        223      222       -1     
Files Coverage Δ
...ugins/coverage/metrics/steps/CoverageRecorder.java 80.85% <100.00%> (+0.63%) :arrow_up:
.../coverage/metrics/steps/CoverageReportScanner.java 76.92% <100.00%> (+1.92%) :arrow_up:
...s/plugins/coverage/metrics/steps/CoverageStep.java 70.90% <100.00%> (+1.38%) :arrow_up:
...s/plugins/coverage/metrics/steps/CoverageTool.java 66.03% <100.00%> (ø)

... and 1 file with indirect coverage changes

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

medianick commented 10 months ago

We ran into this issue and I adopted this new ignoreParsingErrors: true option in our recordCoverage calls. That mostly solved the issue we were encountering, but we now transiently get errors like this (despite the setting):

There is already a child [CLASS] My.Redacted.Class`2 <0> with the name My.Redacted.Class`2 in [FILE] RedactedFile.cs <1, LINE: 88.89% (32/36)>

I have to imagine it is the result of the disambiguation issue documented at https://github.com/danielpalme/ReportGenerator/issues/630 but we don't seem to have any way around it, short of rerunning the build and hoping it works. (We could also add try/catch logic around recordCoverage but depend on its output as a status check.)

I'm working on obtaining the specific coverage reports that seem to cause this, but as I noted, it's transient -- rerunning a build of the same commit will sometimes fail and sometimes work.

uhafner commented 10 months ago

Currently I catch errors on duplicate methods only. I should extend this to duplicate classes as well.