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

cobertura: avoid duplicate file names in files() #82

Merged
merged 4 commits into from
Mar 20, 2018

Conversation

jdef
Copy link
Contributor

@jdef jdef commented Mar 16, 2018

some coverage reports include metrics for multiple classes within the same file. without this change, redundant rows are generated for such reports.

some coverage reports include metrics for multiple classes within the same file. without this change, redundant rows are generated for such reports.
@aconrad
Copy link
Owner

aconrad commented Mar 16, 2018

Thanks @jdef! Can you please provide a screenshot and coverage report for me to understand your duplicates scenario better? Aren't filenames unique?

@aconrad
Copy link
Owner

aconrad commented Mar 16, 2018

Hum, I think I see what you mean. A sample coverage report would still help if you can provide one. Also if you could write a test for it, it would be greatly appreciated.

Add a test to this file https://github.com/aconrad/pycobertura/blob/master/tests/test_cobertura.py, and include a sample coverage report (ideally a small one to spare the size of the git repository). When you call cobertura = make_cobertura() you can pass it the path to the XML file you included that contains duplicates:

def make_cobertura(xml=SOURCE_FILE, *args, **kwargs):

@@ -234,7 +234,8 @@ def files(self):
"""
Return the list of available files in the coverage report.
"""
return [el.attrib['filename'] for el in self.xml.xpath("//class")]
return list(sorted(set(
[el.attrib['filename'] for el in self.xml.xpath("//class")])))
Copy link
Owner

Choose a reason for hiding this comment

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

Can you prevent using sorted() to optimize runtime? Maybe something like:

seen_filenames = set()
filenames = []

for el in self.xml.xpath("//class"):
    filename = el.attrib['filename']
    if filename in seen_filenames:
        continue
    seen_filenames.add(filename)
    filenames.append(filename)

return filenames

@jdef
Copy link
Contributor Author

jdef commented Mar 16, 2018 via email

@jdef
Copy link
Contributor Author

jdef commented Mar 16, 2018

the clock in my VM is off so GH shows the commits out of order, sorry about that

@jdef
Copy link
Contributor Author

jdef commented Mar 16, 2018

@aconrad feedback addressed, PTAL

@jdef
Copy link
Contributor Author

jdef commented Mar 20, 2018

ping

Copy link
Owner

@aconrad aconrad left a comment

Choose a reason for hiding this comment

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

Thanks for your patience and ping @jdef. I meant to find some time to test your change myself. Looks good to me!

@aconrad aconrad merged commit 1fb4d0b into aconrad:master Mar 20, 2018
@jdef
Copy link
Contributor Author

jdef commented Mar 20, 2018

Thanks for merging. Is there a timeline for the next release of this project?

@aconrad
Copy link
Owner

aconrad commented Mar 20, 2018

Just released 0.10.2

@aconrad aconrad mentioned this pull request Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants