Skip to content

Commit 59e0d38

Browse files
author
David Yang
committed
feat: remove sonar.swift.appName and sonar.coverage.otherBinaryNames and replced by sonar.coverage.binaryNames
1 parent 2d9d335 commit 59e0d38

File tree

2 files changed

+39
-34
lines changed

2 files changed

+39
-34
lines changed

sonar-project.properties

+21-9
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,41 @@ sonar.projectKey=prjKey
2020
sonar.projectName=prjName
2121
# Number version (can be found automatically in plist, just comment this line)
2222
sonar.projectVersion=1.0
23+
2324
# Comment if you have a project with mixed ObjC / Swift
2425
sonar.language=swift
26+
2527
# Project description
2628
sonar.projectDescription=prjDescription
29+
2730
# Path to source directories
2831
sonar.sources=SourceDir
2932
# Path to test directories (comment if no test)
3033
sonar.tests=TestDir
34+
3135
# Destination Simulator to run surefire
3236
# As string expected in destination argument of xcodebuild command
3337
# Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2
34-
sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2
38+
sonar.swift.simulator=platform=iOS Simulator,name=iPhone X,OS=latest
39+
3540
# Xcode project configuration (.xcodeproj)
3641
# and use the later to specify which project(s) to include in the analysis (comma separated list)
3742
# Specify either xcodeproj or xcodeproj + xcworkspace
3843
#sonar.swift.project=MyPrj.xcodeproj
3944
#sonar.swift.workspace=MyWrkSpc.xcworkspace
40-
# Specify your appname.
41-
# This will be something like "myApp"
42-
# Use when basename is different from targeted scheme.
43-
# Or when slather fails with 'No product binary found'
44-
# sonar.swift.appName=myApp
45+
4546
# Scheme to build your application
4647
sonar.swift.appScheme=MyScheme
47-
# Specify a list of framework names.
48-
# Use if you want to measure code coverage with slather on them.
49-
# sonar.coverage.otherBinaryNames=myFramework,myOtherFramework
48+
49+
# Specify your appname when different from targeted scheme.
50+
# Or when slather fails with 'No product binary found'
51+
# You can also provide a list of framework names to analyse for coverage.
52+
# This will be something like "myApp" or "myApp,myFramework"
53+
# sonar.coverage.binaryNames=myApp,myFramework
54+
5055
# Configuration to use for your scheme. if you do not specify that the default will be Debug
5156
sonar.swift.appConfiguration=MyConfiguration
57+
5258
##########################
5359
# Optional configuration #
5460
##########################
@@ -57,21 +63,27 @@ sonar.sourceEncoding=UTF-8
5763
# SCM
5864
# sonar.scm.enabled=true
5965
# sonar.scm.url=scm:git:http://xxx
66+
6067
# JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml
6168
# Change it only if you generate the file on your own
6269
# The XML files have to be prefixed by TEST- otherwise they are not processed
6370
# sonar.junit.reportsPath=sonar-reports/
71+
6472
# Lizard report generated by run-sonar.sh is stored in sonar-reports/lizard-report.xml
6573
# Change it only if you generate the file on your own
6674
# sonar.swift.lizard.report=sonar-reports/lizard-report.xml
75+
6776
# Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage-swift.xml
6877
# Change it only if you generate the file on your own
6978
# sonar.swift.coverage.reportPattern=sonar-reports/coverage-swift*.xml
79+
7080
# OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml
7181
# Change it only if you generate the file on your own
7282
# sonar.swift.swiftlint.report=sonar-reports/*swiftlint.txt
83+
7384
# Change it only if you generate the file on your own
7485
# sonar.swift.tailor.report=sonar-reports/*tailor.txt
86+
7587
# Paths to exclude from coverage report (surefire, 3rd party libraries etc.)
7688
# sonar.swift.excludedPathsFromCoverage=pattern1,pattern2
7789
sonar.swift.excludedPathsFromCoverage=.*Tests.*

sonar-swift-plugin/src/main/shell/run-sonar-swift.sh

+18-25
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,8 @@ appScheme=''; readParameter appScheme 'sonar.swift.appScheme'
201201
appConfiguration=''; readParameter appConfiguration 'sonar.swift.appConfiguration'
202202
# The name of your test scheme in Xcode
203203
testScheme=''; readParameter testScheme 'sonar.swift.testScheme'
204-
# The name of your binary file (application)
205-
binaryName=''; readParameter binaryName 'sonar.swift.appName'
206204
# The name of your other binary files (frameworks)
207-
otherBinaryNames=''; readParameter otherBinaryNames 'sonar.coverage.otherBinaryNames'
205+
binaryNames=''; readParameter binaryNames 'sonar.coverage.binaryNames'
208206
# Get the path of plist file
209207
plistFile=`xcodebuild -showBuildSettings -project "${projectFile}" | grep -i 'PRODUCT_SETTINGS_PATH' -m 1 | sed 's/[ ]*PRODUCT_SETTINGS_PATH = //'`
210208
# Number version from plist if no sonar.projectVersion
@@ -336,39 +334,34 @@ if [ "$unittests" = "on" ]; then
336334

337335
echo '\nComputing coverage report\n'
338336

339-
# Build the --exclude flags
340-
excludedCommandLineFlags=""
341-
if [ ! -z "$excludedPathsFromCoverage" -a "$excludedPathsFromCoverage" != " " ]; then
342-
echo $excludedPathsFromCoverage | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh2
343-
while read word; do
344-
excludedCommandLineFlags+=" -i $word"
345-
done < tmpFileRunSonarSh2
346-
rm -rf tmpFileRunSonarSh2
347-
fi
348-
if [ "$vflag" = "on" ]; then
349-
echo "Command line exclusion flags for slather is:$excludedCommandLineFlags"
350-
fi
351-
352337
firstProject=$(echo $projectFile | sed -n 1'p' | tr ',' '\n' | head -n 1)
353338

354339
slatherCmd=($SLATHER_CMD coverage)
355-
if [[ ! -z "$binaryName" ]]; then
356-
slatherCmd+=( --binary-basename "$binaryName")
357-
fi
358-
if [[ ! -z "$otherBinaryNames" ]]; then
359-
echo $otherBinaryNames | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh3
340+
341+
# Build the --binary-basename
342+
if [[ ! -z "$binaryNames" ]]; then
343+
echo $binaryNames | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh3
360344
while read word; do
361-
slatherCmd+=( --binary-basename "$word")
345+
slatherCmd+=(--binary-basename "$word")
362346
done < tmpFileRunSonarSh3
363347
rm -rf tmpFileRunSonarSh3
364348
fi
365349

366-
slatherCmd+=( --input-format profdata $excludedCommandLineFlags --cobertura-xml --output-directory sonar-reports)
350+
# Build the --exclude flags
351+
if [ ! -z "$excludedPathsFromCoverage" -a "$excludedPathsFromCoverage" != " " ]; then
352+
echo $excludedPathsFromCoverage | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh2
353+
while read word; do
354+
slatherCmd+=(-i "$word")
355+
done < tmpFileRunSonarSh2
356+
rm -rf tmpFileRunSonarSh2
357+
fi
358+
359+
slatherCmd+=(--input-format profdata --cobertura-xml --output-directory sonar-reports)
367360

368361
if [[ ! -z "$workspaceFile" ]]; then
369-
slatherCmd+=( --workspace "$workspaceFile")
362+
slatherCmd+=(--workspace "$workspaceFile")
370363
fi
371-
slatherCmd+=( --scheme "$appScheme" "$firstProject")
364+
slatherCmd+=(--scheme "$appScheme" "$firstProject")
372365

373366
echo "${slatherCmd[@]}"
374367

0 commit comments

Comments
 (0)