自动化测试/CI测试

Mac下Sonar Swift的配置使用

2018-02-05  本文已影响134人  colacola

SonarQube安装

准备工作

1、已安装JAVA环境
(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、运行sonar

SonarQube使用

sonarqube默认支持的语言插件,在sonarqube-6.7.1/extensions/plugins 这个文件夹里可以看到。

plugins
其中的backelite-sonar-swift-plugin-0.3.5.jar是从这里下载的。

关于Open source Swift plugin for SonarQube的开源文件

具体操作步骤:
##########################
# 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
report

参考文章

Backelite/sonar-swift

Analyzing with SonarQube Scanner

Sonar Swift实践

上一篇下一篇

猜你喜欢

热点阅读