1、安装sonar-scanner并查看环境变量是否配置成功

1
sonar-scanner -v

2、编辑配置文件sonar-project.properties (D:\sonar-scanner-4.6.2.2472-windows\conf\sonar-project.properties)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#Configure here general information about the environment, such as SonarQube server connection details for example
#No information about specific project should appear here

#----- Default SonarQube server
# 可以是本地localhost也可以是服务器地址,如:localhost:9000
sonar.host.url=http://sonar.xxx.com:9000/

#----- Default source code encoding
sonar.sourceEncoding=UTF-8

# 如果连接远程服务,需要身份验证
sonar.login= zhangsan

sonar.password = 123456

3.在项目根目录新建sonar-project.properties

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# must be unique in a given SonarQube instance
# 你的项目key值
sonar.projectKey=project-name

# --- optional properties ---

# defaults to project key
# 你的项目名称,一般跟projectKey对应
sonar.projectName=project-name

# defaults to 'not provided'
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Defaults to .
# 检查的代码路径
sonar.sources=./src  
 
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

4.进入项目的根路径下,执行命令:sonar-scanner,开始对你的代码进行质量审核

vuex概念图.png