But expression.symbolType() and identifier.symbol() do always return unkown type/unkown symbol when testing the rule with a unit test or with gradle test. The sysout prints: !unknownSymbol!
Is there any reason it does not return the type (ReadWriteLock, Lock,…) ?
I am writing a Sonar Plugin following the documentation I could find.
In my unit tests I get a lot of !unknownSymbol! while getting the variables types (Kind.VARIABLE) in a MethodTree parsing. Only the very classical types like java.lang.String are recognized.
Has anybody a reason for that?
I could solve my problem by getting inspired of: https://github.com/arxes-tolina/sonar-plugins/blob/master/pom.xml
The problem was that Sonar did not had the needed libraries in its classpath at testing time.
In the above mentioned link, take a look at the maven-dependency-plugin section. There you need to include your needed artifacts-dependencies if your problem appears at testing time.
Thanks, I believe that where my issues are too. There are a few missing libraries that prevent the scan from continuing. It’s strange that the plugin is working correctly on SonarQube localhost:9000 though.
18:16:54.614 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for javax
18:16:54.614 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for javax.crypto
18:16:54.626 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for StringBuilder
18:16:54.626 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.package-info
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Synthetic$StringBuilder
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for String
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Synthetic$String
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for String
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Synthetic$String
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for SharedPreferences
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.SharedPreferences
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Synthetic$SharedPreferences
18:16:54.627 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for StringBuilder
18:16:54.628 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Synthetic$StringBuilder
18:16:54.628 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for Constants
18:16:54.628 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Constants
18:16:54.628 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Synthetic$Constants
18:16:54.629 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for Context
18:16:54.629 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Context
18:16:54.629 [main] DEBUG o.s.j.b.loader.SquidClassLoader - .class not found for java.lang.Synthetic$Context