-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
some coverage reports include metrics for multiple classes within the same file. without this change, redundant rows are generated for such reports.
Thanks @jdef! Can you please provide a screenshot and coverage report for me to understand your duplicates scenario better? Aren't filenames unique? |
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 Line 4 in c692f26
|
pycobertura/cobertura.py
Outdated
@@ -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")]))) |
There was a problem hiding this comment.
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
OK, I'll try that. My initial impression was that sorting strings shouldn't
be that intense. I suppose it's probably a bigger issue on a busy CI server
that's processing many large projects at the same time?
…On Fri, Mar 16, 2018 at 1:57 PM, Alexandre Conrad ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In pycobertura/cobertura.py
<#82 (comment)>:
> @@ -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")])))
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
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#82 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACPVLDxDRrKOWmR8BVD49M0ATJiulsyMks5te_z3gaJpZM4St6sO>
.
--
James DeFelice
585.241.9488 (voice)
650.649.6071 (fax)
|
the clock in my VM is off so GH shows the commits out of order, sorry about that |
@aconrad feedback addressed, PTAL |
ping |
There was a problem hiding this 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!
Thanks for merging. Is there a timeline for the next release of this project? |
Just released 0.10.2 |
some coverage reports include metrics for multiple classes within the same file. without this change, redundant rows are generated for such reports.