安装了SonarQube以及Sonar Scanner之后,就需要那代码检测了。当然为了方便我们使用已有现成的demo,知道到对应的git地址下载即可。
1 https://github.com/saurabhjuneja/sonar-example
1 [yun@mini04 python-sonar-runner]$ pwd
2 /app/software/sonar-example-master/projects/languages/python/python-sonar-runner
3 [yun@mini04 python-sonar-runner]$ ll
4 total 12
5 -rw-rw-r-- 1 yun yun 497 Aug 8 2015 README.md
6 -rw-rw-r-- 1 yun yun 341 Aug 8 2015 sonar-project.properties
7 drwxrwxr-x 5 yun yun 93 Aug 8 2015 src
8 -rw-rw-r-- 1 yun yun 298 Aug 8 2015 validation.txt
9 [yun@mini04 python-sonar-runner]$ cat README.md # 查看使用方法
10 This example demonstrates how to analyze a Python project with the SonarQube Runner.
11
12 Prerequisites
13 =============
14 * [SonarQube](http://www.sonarsource.org/downloads/) 4.5 or higher
15 * [SonarQube Runner](http://docs.sonarqube.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner) 2.4 or higher
16 * [SonarQube Python Plugin](http://docs.sonarqube.org/display/SONAR/Python+Plugin) 1.5 or higher
17
18 Usage
19 =====
20 * Analyze the projec with SonarQube using the SonarQube Runner:
21
22 sonar-runner
23 [yun@mini04 python-sonar-runner]$ cat sonar-project.properties # 查看配置信息
24 # Required metadata
25 sonar.projectKey=org.codehaus.sonar:python-simple-sonar-runner
26 sonar.projectName=Python :: Simple Project : SonarQube Runner
27 sonar.projectVersion=1.0
28
29 # Comma-separated paths to directories with sources (required)
30 sonar.sources=src
31
32 # Language
33 sonar.language=py
34
35 # Encoding of the source files
36 sonar.sourceEncoding=UTF-8
1 [yun@mini04 python-sonar-runner]$ pwd
2 /app/software/sonar-example-master/projects/languages/python/python-sonar-runner
3 [yun@mini04 python-sonar-runner]$ ll
4 total 12
5 -rw-rw-r-- 1 yun yun 497 Aug 8 2015 README.md
6 -rw-rw-r-- 1 yun yun 341 Aug 8 2015 sonar-project.properties
7 drwxrwxr-x 5 yun yun 93 Aug 8 2015 src
8 -rw-rw-r-- 1 yun yun 298 Aug 8 2015 validation.txt
9 [yun@mini04 python-sonar-runner]$ /app/sonar-scanner/bin/sonar-scanner # 质量检测