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

Cannot read property 'lines' of undefined #354

Closed
reganheath opened this issue Jan 25, 2022 · 12 comments · Fixed by #374
Closed

Cannot read property 'lines' of undefined #354

reganheath opened this issue Jan 25, 2022 · 12 comments · Fixed by #374
Labels
bug upstream issue in upstream dependency
Milestone

Comments

@reganheath
Copy link

reganheath commented Jan 25, 2022

I have coverage gutters v2.9.1

I am generating code coverage for Erlang using rebar3, then converting the output to Cobertura using https:/covertool/covertool.

The top of the stack is..
[1643108745489][coverageparser][cobertura-parse]: Stacktrace: TypeError: filename: //Dev/game/X/_build/test/covertool/X.covertool.xml Cannot read property 'lines' of undefined
at extractLcovStyleBranches (/***/.vscode-server/extensions/ryanluker.vscode-coverage-gutters-2.9.1/node_modules/cobertura-parse/source/index.js:30:12)
at //.vscode-server/extensions/ryanluker.vscode-coverage-gutters-2.9.1/node_modules/cobertura-parse/source/index.js:77:24
at Array.map (:null:null)
at unpackage (//.vscode-server/extensions/ryanluker.vscode-coverage-gutters-2.9.1/node_modules/cobertura-parse/source/index.js:75:20)
at //.vscode-server/extensions/ryanluker.vscode-coverage-gutters-2.9.1/node_modules/cobertura-parse/source/index.js:134:22
at Parser. (//.vscode-server/extensions/ryanluker.vscode-coverage-gutters-2.9.1/node_modules/xml2js/lib/parser.js:303:18)

Which, I believe, indicates that the c (class) object passed to extractLcovStyleBranches is undefined. Which seems to indicate that the array returned by classesFromPackages has included an 'undefined' element.

I checked classesFromPackages, and compared to the XML I have, which looks like (cut down, removed identifiers, etc)

<coverage timestamp="1643107972566" line-rate="0.564" lines-covered="1598" lines-valid="2832" branch-rate="0.0" branches-covered="0" branches-valid="0" complexity="0" version="1.9.4.1">
  <sources>
      ...
  </sources>
  <packages>
    <package name="X" line-rate="0.0" branch-rate="0.0" complexity="0">
      <classes/>
    </package>
    <package name="P" line-rate="0.026" branch-rate="0.0" complexity="0">
      <classes>
        <class name="C" filename="..." line-rate="0.026" branch-rate="0.0" complexity="0">
          <methods>
            <method name="M" signature="S/5" line-rate="0.0" branch-rate="0.0">
              <lines>
                <line number="145" hits="0" branch="False"/>
                ...
              </lines>
            </method>
          </methods>
          <lines>
            <line number="15" hits="0" branch="False"/>
             ...
          </lines>
        </class>
      </classes>
    </package>
    ...
  </packages>
</coverage>

If I remove all the packages with no classes, e.g.

<package name="X" line-rate="0.0" branch-rate="0.0" complexity="0">
  <classes/>
</package>

Then it works without error.

@ryanluker
Copy link
Owner

@reganheath Thanks for the issue, I will try to dig into it for yeah soon.

To give you something high level to try out, I know cobertura has been annoying for some to get working, so if you are able to use lcov or clover formats for coverage instead... that would be preferable.
https:/ryanluker/vscode-coverage-gutters/blob/master/src/files/coverageparser.ts#L1-L4

I also found this person setup with erlang and the extension with a lcov generate they built. I am no erlang expert though so it might not work with rebar3 🤔 .
https://elixirforum.com/t/lcovex-lcov-file-generator-for-elixir-projects/32057

Maybe that will help?

@reganheath
Copy link
Author

@ryanluker Hi, thanks. No rush on this. GitLab itself handles the coverage data, so we've got that and I can easily write a small script to clean it up for coverage gutters. Thanks!

@ryanluker
Copy link
Owner

ryanluker commented Feb 1, 2022

@reganheath I might close this ticket then as eventually Cobertura will be deprecated given it isn't maintained anymore and will slowly rot... https:/vokal/cobertura-parse Most of the issues that show up like this are due to bugs not being fixed in the upstream package.

We even had to pin the package to a specific commit to get what we needed 😓 .
https:/ryanluker/vscode-coverage-gutters/blob/master/package.json#L281

If we could find a different js / ts package for consuming Cobertura style coverage... then we should definitely switch to that!

@ryanluker
Copy link
Owner

@reganheath I believe this is fixed with #360 possibly.
Keep an eye out for this fix in the 2.10.0 release, otherwise we can always open this ticket again if it didn't help.

@ryanluker ryanluker added this to the 2.10.0 milestone Mar 30, 2022
@ryanluker ryanluker added bug upstream issue in upstream dependency and removed triage labels Mar 30, 2022
@reganheath
Copy link
Author

@ryanluker Hi, unfortunately the bug persists in v2.10.1 unchanged (same stack, same cause, same result).

@reganheath
Copy link
Author

I have created a patch: fschwaiger/cobertura-parse#1

@ryanluker
Copy link
Owner

@reganheath Thanks for the heads up!
Once it is merged in the upstream repo we can update the version here, and it will go out in the next release.

@ryanluker ryanluker modified the milestones: 2.10.0, 2.11.0 May 21, 2022
@ryanluker ryanluker reopened this May 21, 2022
@ryanluker
Copy link
Owner

@reganheath Upstream is merged, so we just need to update the commit hash, do you have an example file we can use to simulate the error and test that it has been fixed?

@reganheath
Copy link
Author

Any file with a package with no classes will do, e.g.
<package name="X" line-rate="0.0" branch-rate="0.0" complexity="0"> <classes/> </package>

@ryanluker
Copy link
Owner

@reganheath This will be fixed in the 2.11.0 release!

@ryanluker
Copy link
Owner

ryanluker commented Aug 1, 2022

@reganheath I just saw that 2.11.0 has a bunch of stuff in it already 😅 if this upcoming release ends up taking longer than a month to finish, I will do a smaller release to get this stuff out and into the marketplace store.

@ryanluker
Copy link
Owner

@reganheath sorry for the delay, 2.10.2 is going out now and includes the cobertura fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug upstream issue in upstream dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants