How implement sonar rules in a custom plugin

Hello,

I am developing a basic rule for java : Avoid the use of useless variables
After analysis, it seems that the class sonar ImmediatelyReturnedVariableCheck.java is part of my rules, but this class is not in the accessible api.

So here is my question: is there a way to call this class in my plugin or do I have to redevelop it?

Hi @nicodavdavidson,
If you don’t want that your custom plugin stops working/compiling each time we release a new java analyzer version, you should only use accessible API.
The only solution for you is to:

  • Duplicate the code that you see in ImmediatelyReturnedVariableCheck
  • Or better: contribute with us to improve ImmediatelyReturnedVariableCheck so it fits your need

Good luck,
Alban

Ok,

So i must duplicate the code and add mine.
I don’t known if i can improve the ImmediatelyReturnedVariableCheck rule cause it already do the right job.

Thanks for your answer @alban.auzeill .

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.