Skip to content

Commit 13bcc0a

Browse files
author
Gilles Grousset
committed
Release 0.1.2
2 parents df12d80 + 7842624 commit 13bcc0a

File tree

8 files changed

+67
-8
lines changed

8 files changed

+67
-8
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ Checkout the [Releases](https://github.com/Backelite/sonar-swift/releases) page.
3838

3939
###Release history
4040

41+
####0.1.2
42+
- SwiftLint 0.5.1 support (new rules added).
43+
- Added *sonar.swift.simulator* key in *sonar-project.properties* to select destination simulator for running tests
44+
- SwiftLint scans source directories only
45+
46+
####0.1.1
47+
- SwiftLint 0.4.0 support (new rules added).
48+
4149
####0.1.0
4250
- Initial release.
4351

@@ -66,7 +74,7 @@ To install slather with profdata support, follow those steps :
6674

6775
###Installation (once for all your Swift projects)
6876
- Download the plugin binary into the $SONARQUBE_HOME/extensions/plugins directory
69-
- Copy [run-sonar.sh](https://rawgithub.com/Backelite/sonar-swift/master/src/main/shell/run-sonar-swift.sh) somewhere in your PATH
77+
- Copy [run-sonar-swift.sh](https://rawgithub.com/Backelite/sonar-swift/master/src/main/shell/run-sonar-swift.sh) somewhere in your PATH
7078
- Restart the SonarQube server.
7179

7280
###Configuration (once per project)

build-and-deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fi
1616
#fi
1717

1818
# Deploy new version of plugin in Sonar dir
19+
rm target/*sources.jar
1920
cp target/*.jar $SONARQUBE_HOME/extensions/plugins
2021

2122
# Stop/start Sonar

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
<groupId>com.backelite.sonarqube</groupId>
2828
<artifactId>sonar-swift-plugin</artifactId>
29-
<version>0.1.1</version>
29+
<version>0.1.2</version>
3030

3131
<packaging>sonar-plugin</packaging>
3232

sonar-project.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ sonar.projectDescription=prjDescription
1515
sonar.sources=SourceDir
1616
# Path to test directories (comment if no test)
1717
sonar.tests=TestDir
18+
19+
# Destination Simulator to run tests
20+
# As string expected in destination argument of xcodebuild command
21+
# Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2
22+
sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2
1823

1924
# Xcode project configuration (.xcodeproj)
2025
# and use the later to specify which project(s) to include in the analysis (comma separated list)

src/main/resources/com/sonar/sqale/swiftlint-model.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@
4545
<chc>
4646
<key>READABILITY</key>
4747
<name>Readability</name>
48+
<chc>
49+
<rule-repo>SwiftLint</rule-repo>
50+
<rule-key>valid_docs</rule-key>
51+
<prop>
52+
<key>remediationFunction</key>
53+
<txt>CONSTANT_ISSUE</txt>
54+
</prop>
55+
<prop>
56+
<key>offset</key>
57+
<val>5</val>
58+
<txt>min</txt>
59+
</prop>
60+
</chc>
4861
<chc>
4962
<rule-repo>SwiftLint</rule-repo>
5063
<rule-key>line_length</rule-key>

src/main/resources/org/sonar/plugins/swiftlint/profile-swiftlint.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<repositoryKey>SwiftLint</repositoryKey>
2828
<key>leading_whitespace</key>
2929
</rule>
30+
<rule>
31+
<repositoryKey>SwiftLint</repositoryKey>
32+
<key>legacy_constructor</key>
33+
</rule>
3034
<rule>
3135
<repositoryKey>SwiftLint</repositoryKey>
3236
<key>nesting</key>
@@ -67,6 +71,10 @@
6771
<repositoryKey>SwiftLint</repositoryKey>
6872
<key>type_name</key>
6973
</rule>
74+
<rule>
75+
<repositoryKey>SwiftLint</repositoryKey>
76+
<key>valid_docs</key>
77+
</rule>
7078
<rule>
7179
<repositoryKey>SwiftLint</repositoryKey>
7280
<key>variable_name</key>

src/main/resources/org/sonar/plugins/swiftlint/rules.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
"description": "Files should not contain leading whitespace.",
4242
"severity": "MINOR"
4343
},
44+
{
45+
"category": "SwiftLint",
46+
"name": "Legacy Constructor",
47+
"key": "legacy_constructor",
48+
"description": "Swift constructors are preferred over legacy convenience functions.",
49+
"severity": "MINOR"
50+
},
4451
{
4552
"category": "SwiftLint",
4653
"name": "Nesting",
@@ -111,11 +118,18 @@
111118
"description": "Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 40 characters in length.",
112119
"severity": "MINOR"
113120
},
121+
{
122+
"category": "SwiftLint",
123+
"name": "Valid Docs",
124+
"key": "valid_docs",
125+
"description": "Documented declarations should be valid.",
126+
"severity": "MINOR"
127+
},
114128
{
115129
"category": "SwiftLint",
116130
"name": "Variable Name",
117131
"key": "variable_name",
118-
"description": "Variable name should only contain alphanumeric characters and start with a a lowercase character. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable.",
132+
"description": "Variable name should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters. In an exception to the above, variable names may start with a capital letter when they are declared static and immutable.",
119133
"severity": "CRITICAL"
120134
},
121135
{

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ echo "Running run-sonar-swift.sh..."
144144

145145
## CHECK PREREQUISITES
146146

147-
# Tests installed tools
148-
## TODO : see original Objc shell
149-
150147
# sonar-project.properties in current directory
151148
if [ ! -f sonar-project.properties ]; then
152149
echo >&2 "ERROR - No sonar-project.properties in current directory"; exit 1;
@@ -169,6 +166,10 @@ srcDirs=''; readParameter srcDirs 'sonar.sources'
169166
# The name of your application scheme in Xcode
170167
appScheme=''; readParameter appScheme 'sonar.swift.appScheme'
171168

169+
# Read destination simulator
170+
destinationSimulator=''; readParameter destinationSimulator 'sonar.swift.simulator'
171+
172+
172173
# The file patterns to exclude from coverage report
173174
excludedPathsFromCoverage=''; readParameter excludedPathsFromCoverage 'sonar.swift.excludedPathsFromCoverage'
174175

@@ -189,10 +190,15 @@ if [ -z "$appScheme" -o "$appScheme" = " " ]; then
189190
echo >&2 "ERROR - sonar.swift.appScheme parameter is missing in sonar-project.properties. You must specify which scheme is used to build your application."
190191
exit 1
191192
fi
193+
if [ -z "$destinationSimulator" -o "$destinationSimulator" = " " ]; then
194+
echo >&2 "ERROR - sonar.swift.simulator parameter is missing in sonar-project.properties. You must specify which simulator to use."
195+
exit 1
196+
fi
192197

193198
if [ "$vflag" = "on" ]; then
194199
echo "Xcode project file is: $projectFile"
195200
echo "Xcode application scheme is: $appScheme"
201+
echo "Destination simulator is: $destinationSimulator"
196202
echo "Excluded paths from coverage are: $excludedPathsFromCoverage"
197203
fi
198204

@@ -220,7 +226,11 @@ echo "<?xml version='1.0' ?><!DOCTYPE coverage SYSTEM 'http://cobertura.sourcefo
220226

221227
echo -n 'Running tests'
222228
runCommand /dev/stdout xcodebuild clean -workspace $workspaceFile -scheme $appScheme
223-
runCommand sonar-reports/xcodebuild.log xcodebuild test -workspace $workspaceFile -scheme $appScheme -sdk iphonesimulator -configuration Debug -enableCodeCoverage YES
229+
buildCmd=(xcodebuild test -workspace $workspaceFile -scheme $appScheme -sdk iphonesimulator -configuration Debug -enableCodeCoverage YES)
230+
if [[ ! -z "$destinationSimulator" ]]; then
231+
buildCmd+=(-destination "$destinationSimulator" -destination-timeout 60)
232+
fi
233+
runCommand sonar-reports/xcodebuild.log "${buildCmd[@]}"
224234
cat sonar-reports/xcodebuild.log | $XCPRETTY_CMD -t --report junit
225235
mv build/reports/junit.xml sonar-reports/TEST-report.xml
226236

@@ -256,7 +266,7 @@ if [ "$swiftlint" = "on" ]; then
256266
while read word; do
257267

258268
# Run SwiftLint command
259-
$SWIFTLINT_CMD > sonar-reports/$(echo $word | sed 's/\//_/g')-swiftlint.txt
269+
$SWIFTLINT_CMD lint --path $word > sonar-reports/$(echo $word | sed 's/\//_/g')-swiftlint.txt
260270

261271
done < tmpFileRunSonarSh
262272
rm -rf tmpFileRunSonarSh

0 commit comments

Comments
 (0)