gpt4 book ai didi

angular - 如何为Angular 7项目设置 Sonar

转载 作者:行者123 更新时间:2023-12-03 17:44:18 24 4
gpt4 key购买 nike

尝试为Angular 7代码库设置Sonarqube,以进行代码覆盖率分析。
获得授权cmd后,我已经安装了Sonarqube并在Admin中创建了一个项目

“” sonar-scanner.bat -D“sonar.projectKey = TestApp” -D“sonar.sources =。” -D“sonar.host.url = http://127.0.0.1:9000” -D“sonar.login = 5089f6d1cc070b3c9e96273405a7e354721030c7”

试图在Angular项目中运行...
它开始扫描项目,但失败了,我是否已配置其他任何文件来运行扫描

“下面是在扫描仪控制台中显示的消息”

INFO: 1024/1024 source files have been analyzed
INFO: Sensor TypeScript analysis [javascript] (done) | time=200377ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=256ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=2605ms
INFO: Sensor SonarTS [typescript]
INFO: Since SonarTS v2.0, TypeScript analysis is performed by SonarJS analyzer v6.0 or later. No TypeScript analysis is performed by SonarTS.
INFO: Sensor SonarTS [typescript] (done) | time=20ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=1038ms
INFO: SCM Publisher SCM provider for this project is: svn
INFO: SCM Publisher 2109 source files to be analyzed
INFO:
INFO:
INFO: SCM Publisher 0/2109 source files have been analyzed (done) | time=28586ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 9:48.956s
INFO: Final Memory: 14M/60M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Error when executing blame for file

最佳答案

步骤1-安装Sonarqube

要安装Sonarqube,请先从https://www.sonarqube.org/downloads/.下载Sonarqube

步骤2-使用Angular 配置 Sonar

运行-npm install sonar-scanner --save-dev
在Angular根目录中创建一个名为sonar-project.properties的文件,并添加以下属性

sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin
sonar.projectKey=test-app
sonar.projectName=test-app
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions=**/node_modules/**
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.typescript.lcov.reportPaths=coverage/lcov.info

步骤3-将Karma代码覆盖范围与Sonarqube 集成

在您的package.json中添加一个名为sonar的脚本
"scripts": {
"sonar": "sonar-scanner"
}

最后,运行以下命令以将Karma覆盖范围与Sonar服务器集成在一起,
npm run sonar

通过导航到 http://localhost:9000/projects,您将直接在Sonar服务器上获得结果

关于angular - 如何为Angular 7项目设置 Sonar ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59902276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com