筆者在IDEA中禁用了SonarLint等各種配置,還是無效,後來在網上找到說是插件的bug,
There was a bug in SonarLint for IntelliJ that prevented the configuration to be properly saved.
It was fixed in the latest version 2.3.2: https://jira.sonarsource.com/browse/SLI-106
About the performance, please make sure you are using the Java analyzer 4.2, as you might be experiencing this problem: https://jira.sonarsource.com/browse/SLI-100.
It is embedded in the latest SonarLint, but if you use the connected mode, you also need to check which version of the Java analyzer is installed in the SonarQube server.
We are always trying to improve performance, so feel free to open a topic in the SonarLint Google group with the verbose analysis log so that we can investigate why it takes so long to analyze the file.
關閉插件以後每次都出現以下日志:
D:\develop\Java\jdk1.8.0_181\bin\java.exe -Dmaven.multiModuleProjectDirectory=F:\xxx\SRC\web -Dmaven.home=D:\develop\apache-maven-3.5.4
-Dclassworlds.conf=D:\develop\apache-maven-3.5.4\bin\m2.conf -Dfile.encoding=UTF-8
-classpath D:\develop\apache-maven-3.5.4\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher
-Didea.version=2018.3.4 -s D:\develop\apache-maven-3.5.4\conf\settings.xml
-Dmaven.repo.local=D:\develop\apache-maven-3.5.4\repo org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.xxx:web >--------------------------
[INFO] Building web 0.3
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.6.0.1398:sonar (default-cli) @ web ---
[INFO] User cache: C:\Users\Administrator\.sonar\cache
[INFO] SonarQube version: 8.1.0
[INFO] Default locale: "zh_CN", source code encoding: "UTF-8"
[WARNING] SonarScanner will require Java 11 to run starting in SonarQube 8.x
[INFO] Load global settings
[INFO] Load global settings (done) | time=63ms
[INFO] Server id: A7EE8CF2-AW82frKWbTHGKwBVU3w-
[INFO] User cache: C:\Users\Administrator\.sonar\cache
[INFO] Load/download plugins
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=38ms
[INFO] Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
[INFO] Load/download plugins (done) | time=78ms
[INFO] Process project properties
[INFO] Process project properties (done) | time=9ms
[INFO] Execute project builders
[INFO] Execute project builders (done) | time=3ms
[INFO] Project key: com.xxx:web
[INFO] Base dir: F:\xxx\SRC\web
[INFO] Working dir: F:\xxx\SRC\web\target\sonar
[INFO] Load project settings for component key: 'com.xxx:web'
[INFO] Load project settings for component key: 'com.xxx:web' (done) | time=9ms
[INFO] Load quality profiles
[INFO] Load quality profiles (done) | time=34ms
[INFO] Load active rules
[INFO] Load active rules (done) | time=339ms
[INFO] Indexing files...
[INFO] Project configuration:
[INFO] 464 files indexed
[INFO] Quality profile for java: p3c profiles
[INFO] Quality profile for xml: Sonar way
[INFO] ------------- Run sensors on module web
[INFO] Load metrics repository
[INFO] Load metrics repository (done) | time=15ms
[INFO] Sensor JavaSquidSensor [java]
[INFO] Configured Java source version (sonar.java.source): 8
[INFO] JavaClasspath initialization
[INFO] JavaClasspath initialization (done) | time=21ms
[INFO] JavaTestClasspath initialization
[INFO] JavaTestClasspath initialization (done) | time=12ms
[INFO] Java Main Files AST scan
[INFO] 228 source files to be analyzed
[INFO] Load project repositories
[INFO] Load project repositories (done) | time=19ms
[INFO] 228/228 source files have been analyzed
[WARNING] Classes not found during the analysis : [javax.annotation.meta.When, org.apache.http.annotation.ThreadingBehavior]
[INFO] Java Main Files AST scan (done) | time=6020ms
[INFO] Java Test Files AST scan
[INFO] 228
由于筆者配置了Maven任務是在編譯前進行代碼品質,于是每次運作項目都會跑這個腳本。很浪費時間。
筆者打開了.idea目錄中的misc.xml删除以下類似代碼,項目就能正常運作不再預先檢查代碼品質了。

<property name="SONARLINT_PRECOMMIT_ANALYSIS" value="true"
"MavenCompilerTasksManager">
<option name="beforeCompileTasks">
<set>
<MavenCompilerTask>
<option name="goal" value="org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar" />
<option name="projectPath" value="$PROJECT_DIR$/pom.xml" />
</MavenCompilerTask>
</set>
</option>
</component>