ryanluker / vscode-coverage-gutters

Display test coverage generated by lcov and xml - works with many languages
https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
MIT License
460 stars 88 forks source link

Loading a clover xml breaks on classes without lines #172

Closed koole closed 5 years ago

koole commented 6 years ago

I was having an issue with clover xml files I generated with phpunit sometimes failing to load:

[1539175884820][coverageservice]: Loading 1 file(s)
[1539175884824][lcovparser][clover-parse]: Error: Cannot read property 'forEach' of undefined
[1539175884824][lcovparser][clover-parse]: Stacktrace: TypeError: Cannot read property 'forEach' of undefined

For me this happens on cases like this, where there's a class with no lines:

<file name="/app/Models/Scenario.php">
  <class name="App\Models\Scenario" namespace="App\Models">
    <metrics complexity="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
  </class>
  <metrics loc="10" ncloc="10" classes="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
</file>

I think I've already found the issue and made a pull request at cvrg-report/clover-json#1 to fix my issue, but I still wanted to report it here in case anyone else using this plugin is having this same issue. If the issue is fixed in clover-json I can make a pull request to update that package in here.

ryanluker commented 6 years ago

@koole thanks for looking into this! if the repo maintainer doesn't get back to you in a couple weeks I would be willing to include your patch version in the extension instead (as long as you also add a small test as well to show that your fix works).

koole commented 5 years ago

Will do! It might be smart to add an updated test to my pull request in the original repo anyway.

ryanluker commented 5 years ago

More examples of this upstream parsing error can be found here https://github.com/ryanluker/vscode-coverage-gutters/issues/180 provided by @neufena

koole commented 5 years ago

I've mentioned the repo owner in a comment manually, as the repository itself has no watchers on GitHub anymore. I've also added a small test to my pull request.

ryanluker commented 5 years ago

@koole FYI, I am hoping to include this fix in the 2.3.0 release (weeks away) so we will either have to use the commit hash of your fork or hopefully just increment the module version if the maintainer gets to that npm release.

koole commented 5 years ago

A new version has been released! 🎉

ryanluker commented 5 years ago

@koole thanks for the reminder! this will be included in the 2.3.0 release https://github.com/ryanluker/vscode-coverage-gutters/commit/c9870a1154b1545da23eecb45ab7c1cd84bf3ead