持续代码质量管理-SonarQube-7.3简单使用

时间:2021-02-05 08:51:44

安装了SonarQube以及Sonar Scanner之后,就需要那代码检测了。当然为了方便我们使用已有现成的demo,知道到对应的git地址下载即可。

1. sonar-examples下载

 https://github.com/saurabhjuneja/sonar-example    

持续代码质量管理-SonarQube-7.3简单使用

2. 案例检测

2.1. 查看配置

 [yun@mini04 python-sonar-runner]$ pwd
/app/software/sonar-example-master/projects/languages/python/python-sonar-runner
[yun@mini04 python-sonar-runner]$ ll
total
-rw-rw-r-- yun yun Aug README.md
-rw-rw-r-- yun yun Aug sonar-project.properties
drwxrwxr-x yun yun Aug src
-rw-rw-r-- yun yun Aug validation.txt
[yun@mini04 python-sonar-runner]$ cat README.md # 查看使用方法
This example demonstrates how to analyze a Python project with the SonarQube Runner. Prerequisites
=============
* [SonarQube](http://www.sonarsource.org/downloads/) 4.5 or higher
* [SonarQube Runner](http://docs.sonarqube.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner) 2.4 or higher
* [SonarQube Python Plugin](http://docs.sonarqube.org/display/SONAR/Python+Plugin) 1.5 or higher Usage
=====
* Analyze the projec with SonarQube using the SonarQube Runner: sonar-runner
[yun@mini04 python-sonar-runner]$ cat sonar-project.properties # 查看配置信息
# Required metadata
sonar.projectKey=org.codehaus.sonar:python-simple-sonar-runner
sonar.projectName=Python :: Simple Project : SonarQube Runner
sonar.projectVersion=1.0 # Comma-separated paths to directories with sources (required)
sonar.sources=src # Language
sonar.language=py # Encoding of the source files
sonar.sourceEncoding=UTF-

2.2. 质量检测

 [yun@mini04 python-sonar-runner]$ pwd
/app/software/sonar-example-master/projects/languages/python/python-sonar-runner
[yun@mini04 python-sonar-runner]$ ll
total
-rw-rw-r-- yun yun Aug README.md
-rw-rw-r-- yun yun Aug sonar-project.properties
drwxrwxr-x yun yun Aug src
-rw-rw-r-- yun yun Aug validation.txt
[yun@mini04 python-sonar-runner]$ /app/sonar-scanner/bin/sonar-scanner # 质量检测

2.3. 浏览器查看

持续代码质量管理-SonarQube-7.3简单使用