|
This post was updated on .
Hi!
While trying to make a plugin to Sonar I have encountered following problem: I save a measure in analysis if it's not set, but next time it is supposed to be set, but when calling "context.getMeasure(myMetric)" the variable which I assign this measure remains null. So my question is: Is this is supposed to happen cause it's some kind of security, or am I doing something wrong? Thanks in advance! |
|
Hi,
That's the expected behavior. The objet "context" relates to the current analysis. Past numeric metrics are available through http://docs.sonarsource.org/3.1/apidocs/index.html?org/sonar/api/batch/TimeMachine.html Regards Simon On 18 June 2012 14:08, Janis Kivitis <[hidden email]> wrote: Hi! |
|
In reply to this post by Janis Kivitis
Hi Janis
I think this thread
http://sonar.15.n6.nabble.com/sonar-dev-help-in-plugin-development-why-some-metrics-of-Sonar-are-empty-tc4999846.html might help you
Regards Patroklos
2012/6/18 Janis Kivitis <[hidden email]> Hi! |
|
My problem is, that I want to store some string measures for some time to compare them, so in some time i don't have to change it. I thought "@dependsUpon" could work fine, but i can't make it working, my variable still is null.
Is this the way I should use dependsUpon ? @DependsUpon public Metric dependsOnFiveDays() { return FastTryMetrics.FASTTRY_FIVE_DAYS; } public void decorate(Resource resource, DecoratorContext context) { Measure test = context.getMeasure(dependsOnFiveDays()); } And about TimeMachine, I was sure I could use it, but i wasn't able to find some examples on how to. Best regards Janis
|
|
Hi Janis, this is not the way to use DependsUpon. You have not to use the dependsOnMethod in the decorate method.
But I think your problem isn't here. For each crossing in the decorator, the context changes. Your metric can contain as many measures as context. So, the measure you saved must be saved in an other context. With the resource, you can get the scope. Scopes are : BlockUnit < ProgramUnit < File < directory < Package < project If you are in a program Unit (a java class), you can get the collection of the measures of the blockUnits (methods) of this class with "context.getChildrenMeasures(YourMetric)". It's the same mechanism for other scopes. I expect I gave you ways to resolve your problem. The problem is that we don't know precisely your goal in your develoment. Regards, Thomas 2012/6/18 Janis Kivitis <[hidden email]> My problem is, that I want to store some string measures for some time to |
| Powered by Nabble | Edit this page |
