Classes not found during the analysis : [org.jaxen.VariableContext]

987 views
Skip to first unread message

Björn Kautler

unread,
Aug 23, 2017, 8:29:24 AM8/23/17
to SonarQube
Hi

We have a class that uses the method org.dom4j.DocumentHelper.parseText(...).
When this class is analysed by the Java ... Files AST scan, this also tries to fully anlyse the class org.dom4j.DocumentHelper.
During this analysis SQ complains that the class org.jaxen.VariableContext cannot be found.
It is correct that this class cannot be found, as it is not in the classpath, due to being an optional dependency of dom4j and thus left out because it is not needed here.
But should this really emit a warning?
DocumentHelper is a class with a bunch of static helper methods and a private constructor.
During runtime it does not care that Jaxen is not in the classpath as the method needing Jaxen classes are not used.

Regards
Björn

Nicolas Peru

unread,
Aug 23, 2017, 8:30:16 AM8/23/17
to Björn Kautler, SonarQube
Hi, 

What's your version of SonarJava ? 

Cheer, 

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/0de19f0b-a71c-4628-9b25-b0ce9dd29e72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Nicolas Peru | SonarSource

Björn Kautler

unread,
Aug 23, 2017, 8:42:00 AM8/23/17
to SonarQube, bjo...@kautler.net
Latest, 4.12.0.11033

Nicolas Peru

unread,
Aug 23, 2017, 8:47:59 AM8/23/17
to Björn Kautler, SonarQube
Hi, 

When doing semantic analysis, SonarJava will try to load the types of the methods within any external dependencies. As such a lookup in the configured classpath will be attempted. 
We want to warn our users in case we did not find some classes : it could mean a bad configuration on user side. However we cannot distinguish legitimate missing classes (like your case) from bad configuration. Hence the warning level. In your case it is harmless but in some cases it can lead to false negative and we want to know about this when analyzing user logs. 

HTH, 

Cheers, 

Björn Kautler

unread,
Aug 23, 2017, 8:54:52 AM8/23/17
to SonarQube, bjo...@kautler.net
Hi,

I surely know the sense of the warning and was grateful when I originally set up the analysis to see that everything is there now.
But is there anything that can be done to get rid of the warning?
Before this method call was introduced, the warning was not present.
With the method call, the warning appears because now the whole class is analysed, though only that one static method of the class is used.
Is there some SQ property that can be set like "it.is.ok.if.following.classes.are.missing = org.jaxen.VariableContext"?
If not, maybe this would be a nice addition, to be able to focus on actual valid warnings?

Regards
Björn

Nicolas Peru

unread,
Aug 23, 2017, 9:39:21 AM8/23/17
to Björn Kautler, SonarQube
Hi, 

There is nothing like this available and we don't have anything plan to go into that direction regarding this. 

Cheers, 


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages