-
Notifications
You must be signed in to change notification settings - Fork 127
Two classes with the same simple name confuse scoverage #27
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
Comments
This is now causing me more problems: I have multiple inner classes with the same name, and File "my/stuff/Foo.scala":
File "my/stuff/Bar.scala":
... (The property " I'll see if I can get a PR together to fix. |
This happens even if the ambiguous name is " I think some DSLs like Spray Routing will trigger this, as they create inner classes named " |
Hi Richard val fqn = (packageName + ".").replace("<empty>.", "") + topLevelClass (and using it for grouping, of course). With this change only top level classes would be shown in Additionally, can you create sample project with Spray Routing generated classes you mentioned? |
After some further investigation, it seems that Spray's DSL is not involved here. Sorry for the confusion. I have uploaded a repro case to https://github.com/RichardBradley/scoverage-27-demo Scoverage is correctly filtering out anonymous classes which are created to capture closures (e.g. for DSLs), but it reports explicit anonymous classes in the report with name " If you have two classes in the same package which both use explicit anonymous classes, then the two classes will have the same simple name but different FQNs, so they will trigger this bug as described at the top of this thread. |
I've updated checked out https://github.com/RichardBradley/scoverage-27-demo, updated |
You're right, the " I have updated the example to demo this issue for inner classes which have the same name instead -- see RichardBradley/scoverage-27-demo@6b0bcf2 |
Perhaps listing "classes" in the report view is asking for trouble. Given that the coverage tool is "line" based, it might be simpler to list "files" in that report view instead? Then we could just ignore all this complexity around anon classes, implied classes for lambdas etc. etc. |
(I really need to update to the latest scoverage version on our big commercial Scala project. I've been putting it off as we wrote quite a bit of custom SBT logic to add scoverage to our "functional" (integration) tests, and it will all need redoing.) |
The latest builds of sbt-scoverage are miles better for playing nicely with On 10 April 2015 at 11:16, Richard Bradley [email protected] wrote:
|
I've tested your modified project. As I commented earlier (#27 (comment)) because val fqn = (packageName + ".").replace("<empty>.", "") + className to val fqn = (packageName + ".").replace("<empty>.", "") + topLevelClass and use for grouping in |
What you said makes sense, either that or enclosingClass. It depends on how we want to handle nested classes. So class Foo {
class Boo {
// function here
}
} do we want that function to be grouped with packageName.Foo.Boo or packageName.Foo or packageName.Boo |
|
@sksamuel, what about this? If you have no objections I will change val fqn = (packageName + ".").replace("<empty>.", "") + topLevelClass and release |
I think we should not use the topLevelClass but the full package + Otherwise: object Foo { The moos would clash. On 17 April 2015 at 09:44, Grzegorz Slowikowski [email protected]
|
There is no full enclosing path stored in |
Of course, we can add whatever we want to the xml (just not remove things I think if we store the full path, the top level type, and the filepath, On 17 April 2015 at 09:57, Grzegorz Slowikowski [email protected]
|
I can do this tonight actually if you'd prefer me to do it ? |
Yes, I don't know Scalac internals. |
I would like to fix this issue and release 1.1.0 ASAP because users are asking for it. |
Yep I can get to around 5pm UK time, shouldn't take long. On 17 April 2015 at 10:12, Grzegorz Slowikowski [email protected]
|
Ping |
@gslowikowski I wasn't able to do this as I didn't have the gpg keys with me while away on business in Washington, which I thought I had . I've released it now. |
Why you've closed this issue? It's not fixed. |
Overzealous. |
#27 use fully-qualified class names to avoid ambiguity in reports
Thanks, @gslowikowski - that's very useful. This should be an easy fix; are you able to create a PR for it? If not, I'll try to fix in the next few days (I don't have Cobertura or anything which expects Cobertura formatted XML output, so I'm not able to test that this actually works, but your comments are specific enough that I can create a fix on that basis). I have created #146 to track this, as it's a separate issue to this one, and this one is now closed. |
Unfortunately I have no time. I have test project, but cannot attach zip file to the issue (not supported file type). |
I found one more bug, with method name of nested class. Source: package a.b.c
object Foo
{
def hello: String = "Hello Foo"
object Boo
{
def hello: String = "Hello Foo.Boo"
object Moo
{
def hello: String = "Hello Foo.Boo.Moo"
}
}
} Fragment of <class
name="a.b.c.Foo.Boo.Moo" filename="a\b\c\Foo.scala" statement-count="1" statements-invoked="1" statement-rate="100.00" branch-rate="100.00">
<methods>
<method name="a.b.c/Moo/hello" statement-count="1" statements-invoked="1" statement-rate="100.00" branch-rate="100.00">
<statements>
<statement
package="a.b.c" class="Moo" class-type="Object" full-class-name="a.b.c.Foo.Boo.Moo" source="C:\my\windows\path\to\the\project\src\main\scala\a\b\c\Foo.scala" method="hello" start="180" end="199" line="13" branch="false" invocation-count="1" ignored="false">
</statement>
</statements>
</method>
</methods>
</class> 1 2 |
(I'm closing this again, as I think this issue "Two classes with the same simple name confuse scoverage" is now fixed and we are now discussing "Cobertura XML output format doesn't exactly match real cobertura format for class names, method names" which is tracked at #146) |
In my comment above I'm writing about |
If a project has two classes with the same simple name in different packages, then the front page of the report will have only one line for that class, and the stats reported on that line will be the aggregate of the two classes. The link will go to the file report for the first of the two classes.
There will be two separate per-file reports correctly generated for the two classes, but they will only be available via the package links.
(This seems pretty minor to me; and it's not actually causing me problems, as we only had two classes with the same simple name due to an oversight, but I thought I'd document it here.)
The text was updated successfully, but these errors were encountered: