typescript sonarqube 打字稿插件:“您必须安装支持该语言的插件”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30237547/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 03:00:34  来源:igfitidea点击:

sonarqube typescript plugin: "You must install a plugin that supports the language"

typescriptsonarqubesonar-runner

提问by laffoyb

I'm trying to setup SonarQube to analyse my TypeScript project using this plugin: https://github.com/Pablissimo/SonarTsPlugin

我正在尝试设置 SonarQube 以使用此插件分析我的 TypeScript 项目:https: //github.com/Pablissimo/SonarTsPlugin

However, I'm encountering an error like:

但是,我遇到了如下错误:

> C:\sonarqube\sonar-runner-2.4\bin\sonar-runner.bat
...
INFO: 
------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 3.006s
Final Memory: 18M/613M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must install a plugin that supports the language 'typescript'
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

My setup: - Windows 7 64 bit - JDK8 (1.8.0) 64 bit - SonarQube 5.1 64 bit

我的设置: - Windows 7 64 位 - JDK8 (1.8.0) 64 位 - SonarQube 5.1 64 位

I've built the plugin from source, and copied the resulting .jar file to my SonarQube installation at C:\sonarqube\sonarqube-5.1\extensions\plugins\sonar-typescript-plugin-0.1-SNAPSHOT.jar.

我已经从源代码构建了插件,并将生成的 .jar 文件复制到我的 SonarQube 安装中C:\sonarqube\sonarqube-5.1\extensions\plugins\sonar-typescript-plugin-0.1-SNAPSHOT.jar

SonarQube is running and serving to port 9000, and I can see at Settings->System->UpdateCenter that the TypeScript plugin is installed, with language keyword typescript.

SonarQube 正在运行并服务于端口 9000,我可以在 Settings->System->UpdateCenter 看到 TypeScript 插件已安装,语言关键字为typescript

Based on this post, it seems I must:

基于这篇文章,看来我必须:

Login to your Sonar instance, click on "Settings" > "Quality profiles" and "Create" on top of the heading for the language you want to use.

登录到您的 Sonar 实例,单击“设置”>“质量配置文件”,然后单击要使用的语言标题顶部的“创建”。

Looking at those settings, I see a Typescript Profilesheading, with a TsLintprofile defined and set to Default.

查看这些设置,我看到一个Typescript Profiles标题,其中TsLint定义了一个配置文件并设置为默认值。

Finally, in my project root directory, I have a file sonar-project.properties

最后,在我的项目根目录中,我有一个文件 sonar-project.properties

# Required metadata
sonar.projectKey=my-ts-project
sonar.projectName=A TypeScript Project
sonar.projectVersion=1.0

# Comma-separated paths to directories with sources (required)
sonar.sources=src

# Language
sonar.language=typescript

# Encoding of the source files
sonar.sourceEncoding=UTF-8

With all this configuration in place, I still receive the sonar-runner error "You must install a plugin that supports the language".

有了所有这些配置,我仍然收到声纳运行器错误“您必须安装支持该语言的插件”。

What am I missing?

我错过了什么?

edit:

编辑:

I tried installing the JavaScript plugin, and I'm seeing the same problem. So this isn't limited to TypeScript. I can run Sonar against Java projects, but no other languages seem to work.

我尝试安装 JavaScript 插件,但遇到了同样的问题。所以这不仅限于 TypeScript。我可以针对 Java 项目运行 Sonar,但似乎没有其他语言可以工作。

回答by laffoyb

Okay, I figured out how to solve this specific problem. The key sonar.languagein my sonar-project.propertiesshould be set to ts, not typescript.

好的,我想出了如何解决这个特定问题。sonar.languagemy 中的键sonar-project.properties应该设置为ts,而不是typescript

# Language
sonar.language=ts

I figured this out by looking at example project corresponding to the javascript plugin: https://github.com/SonarSource/sonar-examples/blob/master/projects/languages/javascript/javascript-sonar-runner/sonar-project.properties. Here, the language is set to jsnot javascript.

我通过查看与 javascript 插件对应的示例项目发现了这一点:https: //github.com/SonarSource/sonar-examples/blob/master/projects/languages/javascript/javascript-sonar-runner/sonar-project.properties. 在这里,语言设置为jsnot javascript

I have to guess that, in general, the language key should be set to the normal file extension for source files? i.e. Java -> .java, JavaScript -> .js, TypeScript -> .ts ... If so, well that's not obvious. Is there any way to confirm this hunch?

我不得不猜测,一般来说,语言键应该设置为源文件的正常文件扩展名?即 Java -> .java, JavaScript -> .js, TypeScript -> .ts ... 如果是这样,那不是很明显。有什么办法可以证实这个预感吗?

回答by Karthik

Here are the Possible sonar.language values

这是可能的 sonar.language 值

 C# => "cs"
 CSS => "css"
 SCSS => "scss"
 Less => "less"
 Java => "java"
 Web => "web"
 XML => "xml"
 JSON => "json"
 JavaScript => "js"

Install the required plugin and run the Scanner using -X switch, you can find the necessary values in the sonar logs.

安装所需的插件并使用 -X 开关运行扫描仪,您可以在声纳日志中找到必要的值。