|
Hi everybody,
I develop a plugin for Sonar and I created some new metrics calculated with the measures of the basic metrics of Sonar. For example, one of my metrics is a mark between 0 and 3 evaluating the size of the methods of the project and calculated with the metric NCLOC. My problem is that I can't catch the measures of some metrics like FUNCTIONS. The number of methods of the project is clearly displayed on the principle dashboard of Sonar and I watched in the source code, the name of the metric displayed is FUNCTIONS. But when I want to catch the value of the measure of FUNCTIONS in my decorator whatever the scope, it is always empty. I have the same problem with the metric DISTANCE. Is anybody have an idea of why these metrics are empty or what can I do to resolve it ? Thank you very much, Thomas Sermier, INRIA, France. |
|
Hi Tomas
I suppose you store the metrics in the database when you compute them ( in Sensor ? )
How do you try to access them in Decorator? Regards Patroklos
2012/6/18 Thomas Sermier <[hidden email]> Hi everybody, |
|
Hi.
No, I don't use sensors because I want to use metrics included in Sonar. These are the metrics which are used in the main dashboard to indicate the number of lines of code, methods, classes, packages etc. So, in my decorator, I write : public void decorate(Resource resource, DecoratorContext context) { if (MeasureUtils.hasValue(context.getMeasure(CoreMetrics.FUNCTIONS))) { make instructions... } but it never enter in this condition, like if the metric Functions is empty. It is strange because in the main dashboard, the number of methods in the project is well displayed and it is precisely this metric (CoreMetrics.FUNCTIONS) which is used. Regards, Thomas 2012/6/18 Papapetrou P.Patroklos <[hidden email]> Hi Tomas |
|
You should declare decorator dependencies :
@DependsUpon public Metric dependsOnFunctions() { return CoreMetrics.FUNCTIONS; } Note that collections are supported : @DependsUpon public Collection<Metric> dependsOnMetrics() { return Arrays.asList(CoreMetrics.FUNCTIONS, CoreMetrics.NCLOC); } On 18 June 2012 11:29, Thomas Sermier <[hidden email]> wrote: Hi. |
|
In reply to this post by thomas sermier
Hi Thomas
I think you should use the @DependsUpon annotation to specify which measures you need.
Here is an example @DependsUpon public Metric dependsOnXYZMetric() { // return here the metric you want to use. } Regards
Patroklos
2012/6/18 Thomas Sermier <[hidden email]> Hi. |
|
In reply to this post by Simon Brandhof
Oops
I didn't notice that Simon had already replied to that ... with a better answer :) Regards Patroklos
2012/6/18 Simon Brandhof <[hidden email]> You should declare decorator dependencies : |
|
Thank you very much for your answers,
that was precisely the problem :) Best regards, Thomas 2012/6/18 Papapetrou P.Patroklos <[hidden email]> Oops |
| Powered by Nabble | Edit this page |
