標籤:nal 圖片 資訊 lan ges code 技術 代碼品質 director
安裝了SonarQube以及Sonar Scanner之後,就需要那代碼檢測了。當然為了方便我們使用已有現成的demo,知道到對應的git地址下載即可。
1. sonar-examples下載
1 https://github.com/saurabhjuneja/sonar-example
2. 案例檢測2.1. 查看配置
1 [[email protected] python-sonar-runner]$ pwd 2 /app/software/sonar-example-master/projects/languages/python/python-sonar-runner 3 [[email protected] 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 [[email protected] python-sonar-runner]$ cat README.md # 查看使用方法10 This example demonstrates how to analyze a Python project with the SonarQube Runner.11 12 Prerequisites13 =============14 * [SonarQube](http://www.sonarsource.org/downloads/) 4.5 or higher15 * [SonarQube Runner](http://docs.sonarqube.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner) 2.4 or higher16 * [SonarQube Python Plugin](http://docs.sonarqube.org/display/SONAR/Python+Plugin) 1.5 or higher17 18 Usage19 =====20 * Analyze the projec with SonarQube using the SonarQube Runner:21 22 sonar-runner23 [[email protected] python-sonar-runner]$ cat sonar-project.properties # 查看配置資訊24 # Required metadata25 sonar.projectKey=org.codehaus.sonar:python-simple-sonar-runner26 sonar.projectName=Python :: Simple Project : SonarQube Runner27 sonar.projectVersion=1.028 29 # Comma-separated paths to directories with sources (required)30 sonar.sources=src31 32 # Language33 sonar.language=py34 35 # Encoding of the source files36 sonar.sourceEncoding=UTF-8
2.2. 品質檢測
1 [[email protected] python-sonar-runner]$ pwd2 /app/software/sonar-example-master/projects/languages/python/python-sonar-runner3 [[email protected] python-sonar-runner]$ ll4 total 125 -rw-rw-r-- 1 yun yun 497 Aug 8 2015 README.md6 -rw-rw-r-- 1 yun yun 341 Aug 8 2015 sonar-project.properties7 drwxrwxr-x 5 yun yun 93 Aug 8 2015 src8 -rw-rw-r-- 1 yun yun 298 Aug 8 2015 validation.txt9 [[email protected] python-sonar-runner]$ /app/sonar-scanner/bin/sonar-scanner # 品質檢測
2.3. 瀏覽器查看
持續代碼品質管理-SonarQube-7.3簡單使用