我正在尝试使用maven支持设置SonarQube(v.4.5.6).我相信我的配置是正确的,但我不能让SonarQube分析运行没有错误.
我的项目依赖项:
org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat org.springframework.boot spring-boot-starter-jetty org.springframework.boot spring-boot-starter-security org.springframework.security spring-security-ldap org.apache.httpcomponents httpclient commons-logging commons-logging org.springframework.boot spring-boot-starter-redis com.google.guava guava ${guava.version} net.logstash.logback logstash-logback-encoder ${logstash-logback-encoder.version} org.springframework.boot spring-boot-starter-test test org.powermock powermock-module-junit4 ${powermock.version} test org.powermock powermock-api-mockito ${powermock.version} test org.springframework.security spring-security-test ${spring-security-test.version} test
声纳Maven的插件:
org.codehaus.mojo sonar-maven-plugin 2.7.1
SonarQube分析会引发以下错误:
[INFO] [19:07:06.235] Source paths: pom.xml, src/main/java [INFO] [19:07:06.235] Test paths: src/test/java [INFO] [19:07:06.235] Binary dirs: target/classes [INFO] [19:07:08.046] Sensor JavaSquidSensor... [INFO] [19:07:08.154] Configured Java source version: none [INFO] [19:07:08.157] JavaClasspath initialization... [INFO] [19:07:08.173] JavaClasspath initialization done: 16 ms [INFO] [19:07:08.173] JavaTestClasspath initialization... [INFO] [19:07:08.202] JavaTestClasspath initialization done: 29 ms [INFO] [19:07:08.412] Java Main Files AST scan... [INFO] [19:07:08.414] 27 source files to be analyzed [ERROR] [19:07:08.849] Class not found: org.springframework.security.openid.OpenIDAuthenticationFilter [ERROR] [19:07:08.850] Class not found: org.springframework.security.openid.OpenIDConsumer [ERROR] [19:07:08.850] Class not found: org.openid4java.consumer.ConsumerManager [ERROR] [19:07:08.850] Class not found: org.springframework.security.openid.OpenIDAuthenticationToken [ERROR] [19:07:08.851] Class not found: org.openid4java.consumer.ConsumerException [ERROR] [19:07:08.851] Class not found: org.springframework.security.openid.AxFetchListFactory [ERROR] [19:07:08.872] Class not found: org.springframework.jdbc.datasource.init.DatabasePopulator [ERROR] [19:07:08.872] Class not found: org.springframework.jdbc.datasource.init.DataSourceInitializer [ERROR] [19:07:09.798] Class not found: javax.annotation.Nullable [INFO] [19:07:10.163] 27/27 source files have been analyzed [INFO] [19:07:10.163] Java Main Files AST scan done: 1751 ms [INFO] [19:07:10.165] Java bytecode scan... [INFO] [19:07:10.238] Java bytecode scan done: 73 ms [INFO] [19:07:10.239] Java Test Files AST scan... [INFO] [19:07:10.239] 17 source files to be analyzed [ERROR] [19:07:10.400] Class not found: org.springframework.security.openid.OpenIDAuthenticationFilter [ERROR] [19:07:10.400] Class not found: org.springframework.security.openid.OpenIDConsumer [ERROR] [19:07:10.401] Class not found: org.openid4java.consumer.ConsumerManager [ERROR] [19:07:10.401] Class not found: org.springframework.security.openid.OpenIDAuthenticationToken [ERROR] [19:07:10.401] Class not found: org.openid4java.consumer.ConsumerException [ERROR] [19:07:10.401] Class not found: org.springframework.security.openid.AxFetchListFactory [INFO] [19:07:11.114] Java Test Files AST scan done: 875 ms [INFO] [19:07:11.114] 17/17 source files have been analyzed
所有提到的类都没有在项目中使用,我对我来说更容易让人感到困惑.
您可以看到分析一直运行到最后但没有说它失败了.分析成功.
这条消息'没有找到类:'是什么意思?
这是由sonarqube java分析器在分析源文件的依赖关系时引发的.例如,如果从spring扩展一个类,sonarqube java analyzer将查找相应的.class
文件.
如果我们有一个规则来计算层次结构级别的数量,那么它将查找此.class文件的依赖关系,依此类推.这意味着它将查找可能不直接在您的项目中的某些类.
此消息是无害的,它只是警告您分析器无法找到某些.class文件,因此您最终可能会得到不太准确的结果和/或您可能希望修复提供给分析的类路径.