Quantcast

Sonar 3.1: Exclude Getters and Setters from public undocumented API

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

Sonar 3.1: Exclude Getters and Setters from public undocumented API

Paul Wellner Bou
Hello,

I am trying to convince our Sonar 3.1 installation to exclude getters
and setters from public undocumented API. I found a little bit of
documentation about this referring to older Sonar versions where squid
was configured as plugin (see
http://skitch.com/freddymallet/diyen/sonar-exclude-getters-and-setters
and http://skitch.com/freddymallet/diyem/sonar-accessors-widget).

If this property (sonar.squid.analyse.property.accessors) is set to
true (default), Sonar is not showing the number of accessors separated
from the methods and the setters are included in the public
undocumented API. If I switch it to false, the number of setters is
shown explicitely (but sonar finds 0 of them, although we have a lot
of getters and setters), but they are still considered as public
undocumented API.

How is squid recognizing getters and setters? Just using the get/set
prefix or with more intelligence?
What do we have to do if we don't want to consider getters and setters
as public undocumented API?

Thanks and regards
Paul.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


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

Re: Sonar 3.1: Exclude Getters and Setters from public undocumented API

Freddy Mallet
Hi Paul,

The main problem here is that we all know what is a getter or a setter but if I would ask a clear definition to all Sonar users I'll get plenty different ones. 

So for Sonar we've used the most basic definitions :
  • A getter should look like this :
${type} getMyField(){
   return myField;
}
  • And a setter should look like this :
void setMyField(${type} ${myFieldValue}}{
   this.myField = ${myFieldValue}
}
  • And something pretty similar for Boolean fields

which means that this is no more a getter or setter if :
  • The setter returns a parameter to chain some calls
  • The setter includes a parameter value check
  • The getter manipulates two different fields
  • ...
Kind regards,
Freddy
-----
Sonar for Continuous Inspection



On Mon, Jul 2, 2012 at 9:55 AM, Paul Wellner Bou <[hidden email]> wrote:
Hello,

I am trying to convince our Sonar 3.1 installation to exclude getters
and setters from public undocumented API. I found a little bit of
documentation about this referring to older Sonar versions where squid
was configured as plugin (see
http://skitch.com/freddymallet/diyen/sonar-exclude-getters-and-setters
and http://skitch.com/freddymallet/diyem/sonar-accessors-widget).

If this property (sonar.squid.analyse.property.accessors) is set to
true (default), Sonar is not showing the number of accessors separated
from the methods and the setters are included in the public
undocumented API. If I switch it to false, the number of setters is
shown explicitely (but sonar finds 0 of them, although we have a lot
of getters and setters), but they are still considered as public
undocumented API.

How is squid recognizing getters and setters? Just using the get/set
prefix or with more intelligence?
What do we have to do if we don't want to consider getters and setters
as public undocumented API?

Thanks and regards
Paul.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



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

Re: Sonar 3.1: Exclude Getters and Setters from public undocumented API

ronald.koster
This post has NOT been accepted by the mailing list yet.
Hi Freddy,

I am using Sonar 3.2 with the "Undocumented API" rule and it works fine except for this: it doesn't recognize a getter as getter when it returns:

this.return myField;

instead of:

return myField;

This is a bug a think.

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

Re: Sonar 3.1: Exclude Getters and Setters from public undocumented API

jcllings
This post has NOT been accepted by the mailing list yet.
My understanding is that there is a standard for knowing what a getter or a setter is:
http://www.oracle.com/technetwork/java/index.html

;-)

Aside from that, you could always use a regular expression.
Loading...