如何在 React Native 中生成 SonarQube 报告?
How to generate SonarQube report in react native?
我正在尝试为我的项目实现 sonarqube 报告,我的 React native 版本是 0.60,我试过了但无法达到我想要的结果
注意:这些说明适用于 SonarQube(社区版 - V8.0)。其他版本设置 SonarQube 的步骤可能不同。
第 1 步:下载 SonarQube
- 下载 SonarQube(社区版 - V8.0):https://www.sonarqube.org/downloads/
- 下载 SonarQube 扫描仪 (V4.2):https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
- 解压 SonarQube
- 解压缩 SonarQube 扫描仪
第 2 步:下载并安装 Java
2. 下载并安装Java SE Development Kit (v11.0.5): https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
步骤 3:设置环境变量
3.在环境变量中添加SonarQube Scanner路径。
一种。右键单击此电脑 -> 属性 -> 高级 -> 环境变量。在系统变量下找到“路径”变量,添加解压SonarQube的文件夹路径。在我的例子中是“C:\Users\ \Desktop\sonar-scanner-4.2-windows\bin”。
4.在环境变量中添加Java路径。
.右键单击此电脑 -> 属性 -> 高级 -> 环境变量。在系统变量下找到“path”变量,添加安装JAVA(JDK)的文件夹路径。在我的例子中是“C:\Program Files\Java\jdk-11.0.5\bin”.
步骤 4:设置属性\n
转到 Sonar Scanner -> conf,然后打开 sonar-scanner.properties 文件。
用以下内容替换文件内容:
# must be unique in a given SonarQube instance
sonar.projectKey=influencer proj
# --- optional properties ---
# defaults to project key
sonar.projectName=ProjectName
# defaults to 'not provided'
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.language=js
sonar.sources=srcPath
sonar.sourceEncoding=UTF-8
sonar.exclusions=./node_modules
sonar.exclusions=./.env
sonar.javascript.lcov.reportPaths=srcPath
sonar.host.url = http://localhost:9000
sonar.javascript.lcov.reportPath=report/lcov.dat
sonar.javascript.node.maxspace=12096
#sonar.ws.timeout=1200
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
进入项目文件夹,创建一个文件sonar-project.properties(文件的扩展名必须是.properties)
将以下内容粘贴到文件中。
# 在给定的 SonarQube 实例中必须是唯一的
# sonar.projectKey=影响者项目
# --- optional properties ---
# defaults to project key
sonar.projectKey=porjectName
# defaults to 'not provided'
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.language=js
sonar.sources=app
sonar.sourceEncoding=UTF-8
sonar.exclusions=./node_modules
sonar.exclusions=./.env
sonar.sources=./src
sonar.host.url = http://localhost:9000
sonar.login=porjectKey
sonar.javascript.lcov.reportPath=report/lcov.dat
sonar.javascript.node.maxspace=4096
sonar.ws.timeout=120
sonar.javascript.lcov.reportPaths=./
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
第 5 步:运行SonarQube 和 SonarScanner
4. 进入SonarQube文件夹->bin->windows-x86-64,打开StartSonar.bat。这应该打开控制台。
5. 打开浏览器,转到 http://localhost:9000 - 您将能够在 运行 扫描器之后在此选项卡上看到结果。
6. 使用以下凭据登录:
用户名:admin
密码:管理员
6. 打开可视代码终端,输入命令“sonar-scanner.bat”。这将扫描项目文件夹。
7. 刷新浏览器。您应该会在浏览器中看到结果。
我正在尝试为我的项目实现 sonarqube 报告,我的 React native 版本是 0.60,我试过了但无法达到我想要的结果
注意:这些说明适用于 SonarQube(社区版 - V8.0)。其他版本设置 SonarQube 的步骤可能不同。 第 1 步:下载 SonarQube
- 下载 SonarQube(社区版 - V8.0):https://www.sonarqube.org/downloads/
- 下载 SonarQube 扫描仪 (V4.2):https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
- 解压 SonarQube
- 解压缩 SonarQube 扫描仪
第 2 步:下载并安装 Java 2. 下载并安装Java SE Development Kit (v11.0.5): https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
步骤 3:设置环境变量 3.在环境变量中添加SonarQube Scanner路径。 一种。右键单击此电脑 -> 属性 -> 高级 -> 环境变量。在系统变量下找到“路径”变量,添加解压SonarQube的文件夹路径。在我的例子中是“C:\Users\ \Desktop\sonar-scanner-4.2-windows\bin”。 4.在环境变量中添加Java路径。 .右键单击此电脑 -> 属性 -> 高级 -> 环境变量。在系统变量下找到“path”变量,添加安装JAVA(JDK)的文件夹路径。在我的例子中是“C:\Program Files\Java\jdk-11.0.5\bin”.
步骤 4:设置属性\n 转到 Sonar Scanner -> conf,然后打开 sonar-scanner.properties 文件。 用以下内容替换文件内容:
# must be unique in a given SonarQube instance
sonar.projectKey=influencer proj
# --- optional properties ---
# defaults to project key
sonar.projectName=ProjectName
# defaults to 'not provided'
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.language=js
sonar.sources=srcPath
sonar.sourceEncoding=UTF-8
sonar.exclusions=./node_modules
sonar.exclusions=./.env
sonar.javascript.lcov.reportPaths=srcPath
sonar.host.url = http://localhost:9000
sonar.javascript.lcov.reportPath=report/lcov.dat
sonar.javascript.node.maxspace=12096
#sonar.ws.timeout=1200
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
进入项目文件夹,创建一个文件sonar-project.properties(文件的扩展名必须是.properties) 将以下内容粘贴到文件中。 # 在给定的 SonarQube 实例中必须是唯一的 # sonar.projectKey=影响者项目
# --- optional properties ---
# defaults to project key
sonar.projectKey=porjectName
# defaults to 'not provided'
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.language=js
sonar.sources=app
sonar.sourceEncoding=UTF-8
sonar.exclusions=./node_modules
sonar.exclusions=./.env
sonar.sources=./src
sonar.host.url = http://localhost:9000
sonar.login=porjectKey
sonar.javascript.lcov.reportPath=report/lcov.dat
sonar.javascript.node.maxspace=4096
sonar.ws.timeout=120
sonar.javascript.lcov.reportPaths=./
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
第 5 步:运行SonarQube 和 SonarScanner 4. 进入SonarQube文件夹->bin->windows-x86-64,打开StartSonar.bat。这应该打开控制台。 5. 打开浏览器,转到 http://localhost:9000 - 您将能够在 运行 扫描器之后在此选项卡上看到结果。 6. 使用以下凭据登录: 用户名:admin 密码:管理员 6. 打开可视代码终端,输入命令“sonar-scanner.bat”。这将扫描项目文件夹。 7. 刷新浏览器。您应该会在浏览器中看到结果。