Quantcast

[sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

thomas sermier
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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

Patroklos Papapetrou
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,

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.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

thomas sermier
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

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,

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.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

Simon Brandhof
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.

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

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,

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.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

Patroklos Papapetrou
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.

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

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,

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.



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

Patroklos Papapetrou
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 :

@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.

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

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,

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.




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] help in plugin development - why some metrics of Sonar are empty ?

thomas sermier
Thank you very much for your answers,

that was precisely the problem :)

Best regards,
Thomas

2012/6/18 Papapetrou P.Patroklos <[hidden email]>
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 :

@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.

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

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,

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.





Loading...