我正在尝试将 sonarqube 服务器绑定到 intellij 中的 sonarlint 插件,以拉入 sonarqube 中的规则集,以向我展示 intellij 内部的问题。
出于某种原因,当我使用 sonarlint 扫描文件时,它没有显示任何错误,但在 sonarqube.com 中,文件存在问题,这使我相信插件在绑定到服务器时存在问题,因为当我删除绑定并设置时地方规则问题开始显现。
在 sonarlint 插件中设置我自己的规则就可以了。但是当我选择将项目绑定到 SonarQube/SonarCloud 并配置选项时,我开始在 sonarlint 插件的日志选项卡中看到一个错误
下面的错误:
Starting SonarTS Server
Deploying bundle to /Users/{{userid}}/Library/Caches/JetBrains/IntelliJIdea2020.3/tmp/sonarlint/.sonartmp_8840237824731938236/15046073373381757830
Failed to start SonarTS Server
java.io.IOException: Cannot run program "node": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at org.sonar.plugin.typescript.ContextualServer.startSonarTSServer(ContextualServer.java:114)
at org.sonar.plugin.typescript.ContextualServer.start(ContextualServer.java:92)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.sonarsource.sonarlint.shaded.org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
at org.sonarsource.sonarlint.shaded.org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
at org.sonarsource.sonarlint.core.container.ComponentContainer$1.start(ComponentContainer.java:272)
at org.sonarsource.sonarlint.shaded.org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
at org.sonarsource.sonarlint.shaded.org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
at org.sonarsource.sonarlint.shaded.org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
at org.sonarsource.sonarlint.shaded.org.picocontainer.behaviors.Stored.start(Stored.java:110)
at org.sonarsource.sonarlint.shaded.org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
at org.sonarsource.sonarlint.shaded.org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
at org.sonarsource.sonarlint.shaded.org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:125)
at org.sonarsource.sonarlint.core.container.storage.StorageContainer.doAfterStart(StorageContainer.java:127)
at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:126)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.start(ConnectedSonarLintEngineImpl.java:118)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.lambda$update$2(ConnectedSonarLintEngineImpl.java:176)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.withRwLock(ConnectedSonarLintEngineImpl.java:330)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.update(ConnectedSonarLintEngineImpl.java:169)
at org.sonarlint.intellij.tasks.BindingStorageUpdateTask.run(BindingStorageUpdateTask.java:96)
at org.sonarlint.intellij.tasks.BindingStorageUpdateTask$2.run(BindingStorageUpdateTask.java:82)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:962)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:472)
at com.intellij.codeWithMe.ClientId$Companion$decorateFunction$1.apply(ClientId.kt:159)
at com.intellij.codeWithMe.ClientId$Companion$decorateFunction$1.apply(ClientId.kt:159)
at com.intellij.codeWithMe.ClientId$Companion$decorateFunction$1.apply(ClientId.kt:159)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:235)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:235)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
... 46 more
扫描打字稿文件时,这是日志输出:
Trigger: ACTION
[Action] 1 file(s) submitted
Configuring analysis with org.sonarlint.intellij.analysis.JavaAnalysisConfigurator
Using connection 'final sonarqube company' for project 'com.company.fc:projectname'
Analysing 'app.component.ts'...
Starting analysis with configuration:
[
projectKey: com.company.fc:projectname
baseDir: /Users/userid/projects/projectname
extraProperties: {sonar.java.target=15, sonar.java.source=15}
inputFiles: [
file:///Users/userid/projects/projectname/src/app/app.component.ts (UTF-8)
]
]
Start analysis
Index files
Language of file 'file:///Users/userid/projects/projectname/src/app/app.component.ts' is detected to
be 'TypeScript'
1 file indexed
Available languages:
* Python => "py"
* Kotlin => "kotlin"
* HTL => "htl"
* JavaScript => "js"
* Ruby => "ruby"
* Scala => "scala"
* Java => "java"
* HTML => "web"
* JSP => "jsp"
* XML => "xml"
* PHP => "php"
* TypeScript => "ts"
* Swift => "swift"
Quality profiles:
* htl: 'AEM HTL Profile' (17 rules)
* java: 'Sonar Way + Craftsmanship + Checkmarx' (1032 rules)
* js: 'Sonar way Recommended' (128 rules)
* jsp: 'FindBugs Security JSP' (4 rules)
* kotlin: 'Sonar way' (30 rules)
* php: 'Sonar way' (101 rules)
* py: 'Sonar way' (31 rules)
* ruby: 'Sonar way' (29 rules)
* scala: 'Sonar way' (28 rules)
* swift: 'Sonar way' (61 rules)
* ts: 'Sonar way recommended' (112 rules)
* web: 'Sonar way' (18 rules)
* xml: 'Sonar way' (4 rules)
'JavaSquidSensor' skipped because there is no related file in current project
'Python Squid Sensor' skipped because there is no related file in current project
'Kotlin Sensor' skipped because there is no related file in current project
'SonarJS' skipped because there is no related file in current project
'ESLint-based SonarJS' skipped because there is no related file in current project
'Ruby Sensor' skipped because there is no related file in current project
'Scala Sensor' skipped because there is no related file in current project
'JavaXmlSensor' skipped because one of the required properties is missing
Execute Sensor: HTML
'XML Sensor' skipped because there is no related file in current project
'PHP sensor' skipped because there is no related file in current project
'Analyzer for "php.ini" files' skipped because there is no related file in current project
Execute Sensor: Contextual SonarTS
Skipped analysis as SonarTS Server is not running
'SonarSwift' skipped because there is no related file in current project
Done in 20ms
Processed 0 issues in 0 ms
Found 0 issues
将 intellij 2020.3.2 与 java 11 一起使用
/ which node
/usr/local/bin/node
/ node -v
v13.10.1
/ npm -v
6.13.7