简体   繁体   English

如何为 Angular 7 项目设置声纳

[英]How to setup sonarqube for Angular 7 project

Trying to setup Sonarqube for Angular 7 code base for code coverage analysis.尝试为 Angular 7 代码库设置 Sonarqube 以进行代码覆盖率分析。 I have Installed the Sonarqube and created a project in Admin after getting the Authorization cmd我已经安装了 Sonarqube 并在获得授权 cmd 后在 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"" "sonar-scanner.bat -D"sonar.projectKey=TestApp" -D"sonar.sources=." -D"sonar.host.url= http://127.0.0.1:9000 " -D"sonar.login= 5089f6d1cc070b3c9e96273405a7e354721030c7""

tried to run in Angular project... its started to scan the project, but failing , do I have configure any other to run the scan试图在 Angular 项目中运行...它开始扫描项目,但失败了,我是否配置了其他任何其他项目来运行扫描

"below is the message showing in scanner console" “以下是扫描仪控制台中显示的消息”

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

Step 1 - Install Sonarqube第 1 步 - 安装 Sonarqube

For installing Sonarqube first download the Sonarqube from https://www.sonarqube.org/downloads/.要安装 Sonarqube,首先从https://www.sonarqube.org/downloads/下载 Sonarqube

Step 2 - Configure Sonar with Angular第 2 步 - 使用 Angular 配置声纳

run - npm install sonar-scanner --save-dev运行 - npm install sonar-scanner --save-dev

Create a file called sonar-project.properties in your Angular root directory and add below attributes在 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

Step 3 - Integrate Karma code coverage with Sonarqube第 3 步 - 将 Karma 代码覆盖率与 Sonarqube 集成

Add a script called sonar to your package.json在 package.json 中添加一个名为 sonar 的脚本

"scripts": {
    "sonar": "sonar-scanner"
}

Finally, run the below command to integrate the Karma coverage with the Sonar server,最后,运行以下命令将 Karma 覆盖范围与声纳服务器集成,

npm run sonar

And you will the result directly on the Sonar server by navigating to http://localhost:9000/projects您将通过导航到http://localhost:9000/projects直接在 Sonar 服务器上查看结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM