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

Computing Portfolio fails due to Pitest plugin #25

Open
johankees opened this issue Jan 2, 2018 · 6 comments
Open

Computing Portfolio fails due to Pitest plugin #25

johankees opened this issue Jan 2, 2018 · 6 comments
Assignees

Comments

@johankees
Copy link
Contributor

johankees commented Jan 2, 2018

Hi,

With SonarQube v6.7 we see issues with computing portfolios when the pitest plugin is installed. The background task fails with the following error:
org.sonar.server.computation.task.projectanalysis.component.VisitException: Visit of Component {key=KEY_NAME,type=VIEW} failed
.....
Caused by: java.lang.IllegalStateException: Value can not be converted to int because current value type is a DOUBLE
at org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureImpl.checkValueType(MeasureImpl.java:80)
at org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureImpl.getIntValue(MeasureImpl.java:50)
at org.sonar.plugins.pitest.PitestComputer.compute(PitestComputer.java:79)
at org.sonar.plugins.pitest.PitestComputer.compute(PitestComputer.java:57)

Odd thing is that this happens for nested portfolios, but not for single portfolios. For example, this will work file
PortfolioA

  • projectA1
  • projectA2

But this fails
Portfolio1 <-- Fails here

  • PortfolioA <-- No issues here
    • projectA1
    • projectA2
  • PortfolioB <-- No issues here
    • projectB1
    • projectB2

Here portfolio A and the configured projects are the same in both cases. It will fail on the top level portfolio btw (Portfolio1).

@johankees
Copy link
Contributor Author

As per SonarSource support:
Alexandre GigleuxToday 4:11 PM
I looked at the code of the Pitest Plugin. At some point it is doing the sum (https://github.com/VinodAnandan/sonar-pitest/blob/master/src/main/java/org/sonar/plugins/pitest/PitestComputer.java#L79) of some metrics (https://github.com/VinodAnandan/sonar-pitest/blob/master/src/main/java/org/sonar/plugins/pitest/PitestComputer.java#L37).
To run this code, the metric must be declared with the Metric.ValueType.INT type.
According to me, the problem is coming from this line: https://github.com/VinodAnandan/sonar-pitest/blob/master/src/main/java/org/sonar/plugins/pitest/PitestComputer.java#L43
The metric MUTATIONS_DATA_KEY is declared as Metric.ValueType.DATA, so there is no way to convert it to an Int to run the sum.
I let you see that with the maintainer of the plugin by raising an Issue here: https://github.com/VinodAnandan/sonar-pitest/issues
Regards

@johankees
Copy link
Contributor Author

johankees commented Jan 2, 2018

Since the error is about expecting an int and getting a double, my guess would be that the issue is with MUTATIONS_KILLED_RATIO / MUTATIONS_KILLED_PERCENT_KEY, since Metric.ValueType.PERCENT is of type Double

@bradflood bradflood self-assigned this Jan 3, 2018
@bradflood
Copy link
Collaborator

@johankees I will fix this when I return from vacation next week.

@johankees
Copy link
Contributor Author

Thanks @bradflood
FYI, I checked this a bit more and added some logging to find out where it breaks. I got the following in the logs:
2018.01.03 14:13:59 ERROR ce[AWC8Xwyl3Nc2CAfF_Hx3][o.s.p.p.PitestComputer] Failed to compute value for pitest_mutations_killed_percent.

For now I've "fixed" this by surrounding "sum += m.getIntValue();" with a try/catch clause, which allowed me to log the above statement.

Hope this helps... Thanks!

@bradflood
Copy link
Collaborator

@johankees great! it looks as if you have a handle on what needs to be fixed, and have built the code. If you want to attempt a fix, that would be great. Send a pull request and we can review it together.

@bradflood
Copy link
Collaborator

PR 26 submitted and merged to catch IllegalStateException when metric is of type Double (as is the case when the metric is killed percent). This issue is kept open until a more general solution is in place. Specifically, we cannot assume that all metrics in the list are integers; when a Portfolio is being computed, a percentage killed will have been calculated and added to the list. Need a deeper understanding that is reflected in PitestComputer and corresponding test.

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

No branches or pull requests

2 participants