Why sonar requires binary files (sonar.binaries)

2019-04-28 20:59发布

问题:

Why sonar requires binary files (sonar.binaries)? How it uses binaries to do what ever it does with the binaries?

回答1:

sonar.binaries is a deprecated property : you should now use sonar.java.binaries

This property is used by the java analysis (so I'm assuming you are analyzing java code).

The analysis is done file by file at source level, and in order to properly do a semantic analysis the java analyzer reads information of external dependencies from the .class files.

Concretely this is how it works : While analyzing A.java which declares :

class A {
   B b;
}

The java analyzer will construct semantic model of class A and for external dependencies look into bytecode for B.class to complete its semantic analysis.

Why is it doing that ? in order to solve type of expressions to have a more accurate analysis. (ie: answering the question : What is the type of b.foo(): we need to find out the definition of foo() method).

This is a deliberate choice of implementation to rely on bytecode for every external dependencies, even if we have the source for them.



标签: sonarqube