SonarQube: Community Edition 7.9.2 (build 30863)
SonarScanner: 4.7.0.2747
Plugins:
sonar-java-plugin-6.15.1.26025.jar
sonar-l10n-zh-plugin-1.29.jar
sonar-java-swagger-plugin-1.0.0.jar(java custome rule)
SonarQube deployed: Docker
Scan command:
sonar-scanner -Dsonar.host.url=http://10.255.202.50:19000 -Dsonar.projectKey=xxx-service -Dsonar.projectName=xxx-service -Dsonar.sourceEncoding=UTF-8 -Dsonar.sources=. -Dsonar.java.binaries=target/classes -Dsonar.java.source=1.8 -Dsonar.java.libraries=D:\\env\\mavenRepo -X
use
sonar.java.libraries=D:\\env\\mavenRepo
paramter bacause I metioned in my another topic: Sonar scanner can’t use Java custome rule
First I use sonar-java-plugin with version: sonar-java-plugin-5.13.1.18282.jar . In this sonarjava version, scanner scan my project takes 2-3 minutes.
But I encountered problems when I want to get collection generics : List<UserAddDTO>
, there are no List<Type> typeArguments()
method in class org.sonar.plugins.java.api.semantic.Type
interface in version 5.13.1.18282, so I had no choice but upgrade the sonarjava version greater than 6.3.x to use typeArguments()
method. At last , I take the version: 6.15.1.26025
In sonar-java-plugin-6.15.1.26025.jar version, scan the same project whth same paramter, it takes 30 minutes to finished . After I compared the debug log, I find with >6.3.x version, every file takes > 3s .
18:18:46 10:18:45.908 DEBUG: Analysis time of src/main/java/com/xxx/xxx/xxx/service/dao/SystemParamMapper.java (3086ms)
18:18:46 10:18:45.909 DEBUG: 'src/main/java/com/xxx/xxx/xxx/service/dao/TiDccClueActDelMapper.java' generated metadata with charset 'UTF-8'
18:18:49 10:18:49.241 DEBUG: Analysis time of src/main/java/com/xxx/xxx/xxx/service/dao/TiDccClueActDelMapper.java (3333ms)
18:18:49 10:18:49.242 DEBUG: 'src/main/java/com/xxx/xxx/xxx/service/dao/TiDccClueActMapper.java' generated metadata with charset 'UTF-8'
18:18:52 10:18:52.441 INFO: 42/207 files analyzed, current file: src/main/java/com/xxx/xxx/xxx/service/dao/TiDccClueActMapper.java
18:18:52 10:18:52.514 DEBUG: Analysis time of src/main/java/com/xxx/xxx/xxx/service/dao/TiDccClueActMapper.java (3273ms)
After I realized this, I change the sonarjava version from 6.3.x - 6.15.x , it has same problem.
Then I rollback the version to sonar-java-plugin-5.13.1.18282.jar, scan same project only takes 2-3 minuts.
I don’t know why, In this topic Sonar Scanner taking too long for analyzing,
Ann said MMF-1870 89 - SonarJava 6.3: improve performance
. But in my case , It is not improve performance, but greatly reduced.