Hi Nicolas,
My approach was based on the implementation of the lock/unlock rule that is part of sonar-java. However you are right, it can be written as a regular rule :-)
Although that still needed some other modifications (not using import org.sonar.java.model.expression.MethodInvocationTreeImpl and TypeJavaSymbol which are also not part of the api).
I do find it annoying that using non-api classes does work from within Unit-tests, but fails at runtime in SonarQube. Is there a way to see this while unit-testing ?
My usual work approach is:
- write the example class that has some bug-pattern I want to track in Sonar,
- then write the unit-test,
- then create a rule based on the closest example from sonar-java,
- then work on this rule until it passes the test...
it is quite annoying to lose that sense of victory of passing the test, when it turns out your code will 'never' work in actual sonar, only in the test-suite :-)
How does sonar prevent me from using those classes, and is it possible to do that for unit-tests, to detect the problem early ?
Also somewhat related to my fan-out rule question: is there any way to retrieve the fan in of a method (preferably multi-module). If it is not possible, is it on a roadmap ?
Kind Regards,
Arjen