Giter Club home page Giter Club logo

Comments (4)

Bachmann1234 avatar Bachmann1234 commented on July 22, 2024

So the problem seems to be in this section of the code

# cobertura sometimes provides the sources for the measurements
        # within it. If we have that we outta use it
        sources = xml_document.findall('sources/source')
        sources = [source.text for source in sources]
        classes = [class_tree
                   for class_tree in xml_document.findall(".//class")
                   or []]

        classes = (
            [clazz for clazz in classes if
             src_abs_path in [
                 self._to_unix_path(
                     os.path.join(
                         source.strip(),
                         clazz.get('filename')
                     )
                 ) for source in sources]]
            or
            [clazz for clazz in classes if
             self._to_unix_path(clazz.get('filename')) == src_abs_path]
            or
            [clazz for clazz in classes if
             self._to_unix_path(clazz.get('filename')) == src_rel_path]
        )

We are basically hitting a NPE of sorts when hitting this statement

            [clazz for clazz in classes if
             src_abs_path in [
                 self._to_unix_path(
                     os.path.join(
                         source.strip(),
                         clazz.get('filename')
                     )
                 ) for source in sources]]

So some element of the sources array is None

What this tells me is that there is something missing in the cobertura xml that we assume is there. Is there anyway you can share it here?

from diff_cover.

hjqgloria avatar hjqgloria commented on July 22, 2024

Hi Bachmann1234,

Thanks for your quick answer!
There is an empty source element at the beginning of the xml file:

<coverage line-rate="0.178" branch-rate="0.348" version="1.9" timestamp="1545037553" lines-covered="675" lines-valid="3787" branches-covered="260" branches-valid="747">
<sources>
<source></source>
</sources>
I removed the empty element then it worked. Is it possible for diff-cover remove the check on the empty elements?

from diff_cover.

Bachmann1234 avatar Bachmann1234 commented on July 22, 2024

I'll look into it this week if I can. Should not be a hard change

from diff_cover.

Bachmann1234 avatar Bachmann1234 commented on July 22, 2024

Give https://pypi.org/project/diff-cover/1.0.6/ a shot

from diff_cover.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.