SonarQube 程式碼品質分析工具

建立 SonarQube Server

下載 SonarQube

下載最新的 Java jre

執行 StartSonar.bat

進入 http://localhost:9000 就可以看到啟動成功

新增一個專案





這時候就會產生一個專案的key 給掃描驗證使用 4e4602940368f811feba160cc8797ac455ca65d8

掃描自己的程式(Analyzing with SonarScanner for MSBuild)

下載 Analyzing with SonarScanner for MSBuild

先設定環境變數

1
D:\sonarqube-7.4\bin\sonar-scanner-msbuild-4.4.2.1543-net46

建立 SonaQube 專案,它會在專案目錄底下建立 .sonarqube 資料夾

k:”{Project Index}” 在 sonarquble 上面建立的 key
n:”{Project Name}” 要掃描的專案名稱

1
SonarQube.Scanner.MSBuild.exe begin /k:"4e4602940368f811feba160cc8797ac455ca65d8" /n:"MyConsolTest" /v:"1.0"

執行 Msbuild

1
"C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild.exe" MyConsolTest.sln /t:Rebuild

執行掃描

1
SonarQube.Scanner.MSBuild.exe end

參考