部署本地 sonarQube 完整 过程 :本地SonarQube部署 静态测试_xhc6666的博客-CSDN博客
1. 先 在本机上 运行 sonarQube 服务 在localhost:9000 端口 进入 sonarQube页面,详细见上述链接
2. 随便准备一个JAVA 项目,编写测试用的代码:
方法参数未使用 + 死循环 看能否检测出来
3. 在sonarQube 页面新建一个测试项目
创建令牌 选择 方法,我用的第一种
4. 在项目的根目录 添加 sonar-project.properties 文件
# must be unique in a given SonarQube instance sonar.projectKey=homework0 # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=homework0 sonar.projectVersion=1.0.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # This property is optional if sonar.modules is set. sonar.sources=./ sonar.java.sources=**/src sonar.java.binaries=** sonar.exclusions=**/*Test.java,**/Test*.java, **/*.js, **/*.htm*, **/*.css, **/target/**, **/resources/**, **/.settings/** # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8
5. 打开CMD 进入当前项目 目录 接着输入sonar-scanner
等待结束
6. 回到sonarQube 网页 刷新
有一个 BUG 进入查看
7. 修改BUG
回到项目,将有BUG的地方修改 我直接删除死循环
再次 sonarQube 检测
页面刷新 BUG 去除
一次简单的 静态检测完成