[sonar-dev] A few SonarQube Rules

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[sonar-dev] A few SonarQube Rules

clement escoffier
Hello,

We have implemented a few rules (3 to be exact) that you may find interesting. They are quite simple, but if you need them, feel free to use them.

The code source is there: https://github.com/Axway/sonar-rules.

The rules are:

* Unused Not Annotated Private Field - check that non annotated private fields are used
* Unused Not Annotated Private Method - check that non annotated private methods are called
* Caught Exception Touched - check that exception are used in catch block

The two first rules are made to ignore annotated fields and methods in classes. So replace the related rules provided by SonarQube. The last one is reducing the strictness of the current rules checking that the exception context is kept. In our case, in a lot of places we don't care about the context, and using the message is enough.

Cheers,

Clement
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] A few SonarQube Rules

Fabrice Bellingard-4
Thanks Clement for the contribution! 


Best regards,

Fabrice BELLINGARD | SonarSource
SonarQube Platform Product Manager
http://sonarsource.com

On Tue, May 12, 2015 at 5:18 PM, clement escoffier <[hidden email]> wrote:
Hello,

We have implemented a few rules (3 to be exact) that you may find interesting. They are quite simple, but if you need them, feel free to use them.

The code source is there: https://github.com/Axway/sonar-rules.

The rules are:

* Unused Not Annotated Private Field - check that non annotated private fields are used
* Unused Not Annotated Private Method - check that non annotated private methods are called
* Caught Exception Touched - check that exception are used in catch block

The two first rules are made to ignore annotated fields and methods in classes. So replace the related rules provided by SonarQube. The last one is reducing the strictness of the current rules checking that the exception context is kept. In our case, in a lot of places we don't care about the context, and using the message is enough.

Cheers,

Clement

DEG
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] A few SonarQube Rules

DEG
This post has NOT been accepted by the mailing list yet.
Will these rules be added?
I can surely use them :-)

For the rule S1068 the class UnusedPrivateFieldCheck.java checks for lombok annotations but not for the javax.persistence.* which should be more frequent i guess. I do not want to expose my internal db id outsuide of my class.

So i have no getter and setter for it.

@Id
@Column(name = "AAA", nullable = false)
private long id;

But unfortunately this then violates the rule S1068
So the Annotation rule would be usefull :-)