Mac下Sonar Swift的配置使用

SonarQube安裝

準(zhǔn)備工作

1、已安裝JAVA環(huán)境
(Download Java for Mac OS X https://www.java.com/en/download/mac_download.jsp
http://www.oracle.com/technetwork/java/javase/downloads/index.html

2、下載SonarQube與SonarQube Runner

下載地址:

SonarQube

SonarQube Scanner

3、運(yùn)行sonar

  • 解壓sonarqube-6.7.1.zip
  • 通過終端命令行cd到sonarqube解壓目錄下的/bin/macosx-universal-64文件夾
  • 執(zhí)行./sonar.sh startar-scanner
  • 瀏覽器訪問http://localhost:9000
  • 出現(xiàn)以下頁面,表示安裝成功


    about

SonarQube使用

sonarqube默認(rèn)支持的語言插件,在sonarqube-6.7.1/extensions/plugins 這個(gè)文件夾里可以看到。

plugins

其中的backelite-sonar-swift-plugin-0.3.5.jar是從這里下載的。

關(guān)于Open source Swift plugin for SonarQube的開源文件

具體操作步驟:
  • 拷貝backelite-sonar-swift-plugin-0.3.5.jar文件到sonarqube-6.7.1/extensions/plugins里
  • 下載run-sonar-swift.sh 文夾拷貝到swift項(xiàng)目的根目錄下(和你的projext.xcodeproj 文件同級)
  • 下載sonar-project.properties文件拷貝到swift項(xiàng)目的根目錄下(和你的projext.xcodeproj 文件同級)
  • 編輯sonar-project.properties文件,根據(jù)swift項(xiàng)目修改其中的參數(shù)
    sonar-project.properties文件
##########################
# Required configuration #
##########################

# Project key will also be used for binary file 
sonar.projectKey=prjKey
sonar.projectName=prjName
sonar.projectVersion=1.0
# Comment if you have a project with mixed ObjC / Swift
sonar.language=swift

# Project description
sonar.projectDescription=prjDescription

# Path to source directories
# 修改為swift的路徑
sonar.sources=SourceDir
# Path to test directories (comment if no test)
sonar.tests=TestDir

# Destination Simulator to run tests
# As string expected in destination argument of xcodebuild command
# Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2
sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2

# Xcode project configuration (.xcodeproj)
# and use the later to specify which project(s) to include in the analysis (comma separated list)
# Specify either xcodeproj or xcodeproj + xcworkspace
#指定 xcodeproj 或 xcodeproj + xcworkspace
#sonar.swift.project=MyPrj.xcodeproj
#sonar.swift.workspace=MyWrkSpc.xcworkspace

# Specify your appname.
# This will be something like "myApp"
# Use when basename is different from targeted scheme. 
# Or when slather fails with 'No product binary found'
# sonar.swift.appName=myApp

# Scheme to build your application
sonar.swift.appScheme=MyScheme

# Configuration to use for your scheme. if you do not specify that the default will be Debug
sonar.swift.appConfiguration=MyConfiguration

# Encoding of the source code
sonar.sourceEncoding=UTF-8

sonar.swift.excludedPathsFromCoverage=.*Tests.*

sonar.swift.tailor.config=--max-line-length=100 --max-file-length=500 --max-name-length=40 --max-name-length=40 --min-name-length=4
  • 終端命令行打開swift項(xiàng)目,執(zhí)行sonar-scanner
  • 分析結(jié)束后,終端會(huì)顯示比如INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/Kickstarter,打開提示的地址,可以看到分析結(jié)果。
report

參考文章

Backelite/sonar-swift

Analyzing with SonarQube Scanner

Sonar Swift實(shí)踐

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 新晉測試小白最近在研究sonarqube的靜態(tài)代碼檢查,整理了關(guān)于sonarqube 如何在mac os x系統(tǒng)下...
    測試小白_stone閱讀 2,076評論 0 1
  • 1.SonarQube Sonar的功能:是一個(gè)用于代碼質(zhì)量管理的開源平臺(tái),用于管理源代碼的質(zhì)量,可以從七個(gè)維度檢...
    Broom閱讀 9,564評論 0 6
  • CentOS MySQL SonarQube SonarQube Scanner 針對 Jacoco + Jenk...
    納愛斯閱讀 20,446評論 6 9
  • 夏日余熱還沒有散去,六人的宿舍風(fēng)扇還在嘩嘩地響,偏偏大姨媽來了,痛得我緊緊裹著被子還滿身冷汗,你答對了,我是那種會(huì)...
    蝸?;丶?/span>閱讀 213評論 0 0
  • 兒時(shí)住在大雜院,清晨總是伴著炊煙和鍋碗瓢盆的交響。老嬸早早給漢舅舀起稠稠的2大碗白粥,漢舅吃早餐的時(shí)候,媽媽也開始...
    mimi播報(bào)閱讀 403評論 4 4

友情鏈接更多精彩內(nèi)容