Skip to content

Commit 7311e79

Browse files
authored
Merge pull request Idean#78 from marcus174/feature-swiftlint-18-support
Adding SwiftLint 0.18.1 support
2 parents eda38b7 + 320b633 commit 7311e79

File tree

3 files changed

+194
-13
lines changed

3 files changed

+194
-13
lines changed

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

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,110 @@
894894
<txt>min</txt>
895895
</prop>
896896
</chc>
897+
<chc>
898+
<rule-repo>SwiftLint</rule-repo>
899+
<rule-key>discarded_notification_center_observer</rule-key>
900+
<prop>
901+
<key>remediationFunction</key>
902+
<txt>CONSTANT_ISSUE</txt>
903+
</prop>
904+
<prop>
905+
<key>offset</key>
906+
<val>5</val>
907+
<txt>min</txt>
908+
</prop>
909+
</chc>
910+
<chc>
911+
<rule-repo>SwiftLint</rule-repo>
912+
<rule-key>explicit_type_interface</rule-key>
913+
<prop>
914+
<key>remediationFunction</key>
915+
<txt>CONSTANT_ISSUE</txt>
916+
</prop>
917+
<prop>
918+
<key>offset</key>
919+
<val>5</val>
920+
<txt>min</txt>
921+
</prop>
922+
</chc>
923+
<chc>
924+
<rule-repo>SwiftLint</rule-repo>
925+
<rule-key>fatal_error_message</rule-key>
926+
<prop>
927+
<key>remediationFunction</key>
928+
<txt>CONSTANT_ISSUE</txt>
929+
</prop>
930+
<prop>
931+
<key>offset</key>
932+
<val>5</val>
933+
<txt>min</txt>
934+
</prop>
935+
</chc>
936+
<chc>
937+
<rule-repo>SwiftLint</rule-repo>
938+
<rule-key>for_where</rule-key>
939+
<prop>
940+
<key>remediationFunction</key>
941+
<txt>CONSTANT_ISSUE</txt>
942+
</prop>
943+
<prop>
944+
<key>offset</key>
945+
<val>5</val>
946+
<txt>min</txt>
947+
</prop>
948+
</chc>
949+
<chc>
950+
<rule-repo>SwiftLint</rule-repo>
951+
<rule-key>identifier_name</rule-key>
952+
<prop>
953+
<key>remediationFunction</key>
954+
<txt>CONSTANT_ISSUE</txt>
955+
</prop>
956+
<prop>
957+
<key>offset</key>
958+
<val>5</val>
959+
<txt>min</txt>
960+
</prop>
961+
</chc>
962+
<chc>
963+
<rule-repo>SwiftLint</rule-repo>
964+
<rule-key>implicitly_unwrapped_optional</rule-key>
965+
<prop>
966+
<key>remediationFunction</key>
967+
<txt>CONSTANT_ISSUE</txt>
968+
</prop>
969+
<prop>
970+
<key>offset</key>
971+
<val>5</val>
972+
<txt>min</txt>
973+
</prop>
974+
</chc>
975+
<chc>
976+
<rule-repo>SwiftLint</rule-repo>
977+
<rule-key>notification_center_detachment</rule-key>
978+
<prop>
979+
<key>remediationFunction</key>
980+
<txt>CONSTANT_ISSUE</txt>
981+
</prop>
982+
<prop>
983+
<key>offset</key>
984+
<val>5</val>
985+
<txt>min</txt>
986+
</prop>
987+
</chc>
988+
<chc>
989+
<rule-repo>SwiftLint</rule-repo>
990+
<rule-key>redundant_discardable_let</rule-key>
991+
<prop>
992+
<key>remediationFunction</key>
993+
<txt>CONSTANT_ISSUE</txt>
994+
</prop>
995+
<prop>
996+
<key>offset</key>
997+
<val>5</val>
998+
<txt>min</txt>
999+
</prop>
1000+
</chc>
8971001
</chc>
8981002
</chc>
8991003
<chc>

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

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
<repositoryKey>SwiftLint</repositoryKey>
5656
<key>cyclomatic_complexity</key>
5757
</rule>
58+
<rule>
59+
<repositoryKey>SwiftLint</repositoryKey>
60+
<key>discarded_notification_center_observer</key>
61+
</rule>
5862
<rule>
5963
<repositoryKey>SwiftLint</repositoryKey>
6064
<key>dynamic_inline</key>
@@ -75,6 +79,14 @@
7579
<repositoryKey>SwiftLint</repositoryKey>
7680
<key>explicit_init</key>
7781
</rule>
82+
<rule>
83+
<repositoryKey>SwiftLint</repositoryKey>
84+
<key>explicit_type_interface</key>
85+
</rule>
86+
<rule>
87+
<repositoryKey>SwiftLint</repositoryKey>
88+
<key>fatal_error_message</key>
89+
</rule>
7890
<rule>
7991
<repositoryKey>SwiftLint</repositoryKey>
8092
<key>file_header</key>
@@ -87,6 +99,10 @@
8799
<repositoryKey>SwiftLint</repositoryKey>
88100
<key>first_where</key>
89101
</rule>
102+
<rule>
103+
<repositoryKey>SwiftLint</repositoryKey>
104+
<key>for_where</key>
105+
</rule>
90106
<rule>
91107
<repositoryKey>SwiftLint</repositoryKey>
92108
<key>force_cast</key>
@@ -111,10 +127,18 @@
111127
<repositoryKey>SwiftLint</repositoryKey>
112128
<key>generic_type_name</key>
113129
</rule>
130+
<rule>
131+
<repositoryKey>SwiftLint</repositoryKey>
132+
<key>identifier_name</key>
133+
</rule>
114134
<rule>
115135
<repositoryKey>SwiftLint</repositoryKey>
116136
<key>implicit_getter</key>
117137
</rule>
138+
<rule>
139+
<repositoryKey>SwiftLint</repositoryKey>
140+
<key>implicitly_unwrapped_optional</key>
141+
</rule>
118142
<rule>
119143
<repositoryKey>SwiftLint</repositoryKey>
120144
<key>large_tuple</key>
@@ -159,6 +183,10 @@
159183
<repositoryKey>SwiftLint</repositoryKey>
160184
<key>nimble_operator</key>
161185
</rule>
186+
<rule>
187+
<repositoryKey>SwiftLint</repositoryKey>
188+
<key>notification_center_detachment</key>
189+
</rule>
162190
<rule>
163191
<repositoryKey>SwiftLint</repositoryKey>
164192
<key>number_separator</key>
@@ -195,6 +223,10 @@
195223
<repositoryKey>SwiftLint</repositoryKey>
196224
<key>prohibited_super_call</key>
197225
</rule>
226+
<rule>
227+
<repositoryKey>SwiftLint</repositoryKey>
228+
<key>redundant_discardable_let</key>
229+
</rule>
198230
<rule>
199231
<repositoryKey>SwiftLint</repositoryKey>
200232
<key>redundant_nil_coalescing</key>
@@ -283,10 +315,6 @@
283315
<repositoryKey>SwiftLint</repositoryKey>
284316
<key>valid_ibinspectable</key>
285317
</rule>
286-
<rule>
287-
<repositoryKey>SwiftLint</repositoryKey>
288-
<key>variable_name</key>
289-
</rule>
290318
<rule>
291319
<repositoryKey>SwiftLint</repositoryKey>
292320
<key>vertical_parameter_alignment</key>

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

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@
9090
"description": "Complexity of function bodies should be limited.",
9191
"severity": "CRITICAL"
9292
},
93+
{
94+
"key": "discarded_notification_center_observer",
95+
"category": "SwiftLint",
96+
"name": "Discarded Notification Center Observer",
97+
"description": "When registing for a notification using a block, the opaque observer that is returned should be stored so it can be removed later.",
98+
"severity": "MINOR"
99+
},
93100
{
94101
"key": "dynamic_inline",
95102
"category": "SwiftLint",
@@ -125,6 +132,20 @@
125132
"description": "Explicitly calling .init() should be avoided.",
126133
"severity": "MINOR"
127134
},
135+
{
136+
"key": "explicit_type_interface",
137+
"category": "SwiftLint",
138+
"name": "Explicit Type Interface",
139+
"description": "Properties should have a type interface",
140+
"severity": "MINOR"
141+
},
142+
{
143+
"key": "fatal_error_message",
144+
"category": "SwiftLint",
145+
"name": "Fatal Errror Message",
146+
"description": "A fatalError call should have a message.",
147+
"severity": "MINOR"
148+
},
128149
{
129150
"key": "file_header",
130151
"category": "SwiftLint",
@@ -146,6 +167,13 @@
146167
"description": "Prefer using `.first(where:)` over `.filter { }.first` in collections.",
147168
"severity": "MINOR"
148169
},
170+
{
171+
"key": "for_where",
172+
"category": "SwiftLint",
173+
"name": "For Where",
174+
"description": "`where` clauses are preferred over a single `if` inside a `for`.",
175+
"severity": "MINOR"
176+
},
149177
{
150178
"key": "force_cast",
151179
"category": "SwiftLint",
@@ -188,13 +216,27 @@
188216
"description": "Generic type name should only contain alphanumeric characters, start with an uppercase character and span between 1 and 20 characters in length.",
189217
"severity": "MINOR"
190218
},
219+
{
220+
"key": "identifier_name",
221+
"category": "SwiftLint",
222+
"name": "Identifier Name",
223+
"description": "Identifier names 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. Variable names should not be too long or too short.",
224+
"severity": "MINOR"
225+
},
191226
{
192227
"key": "implicit_getter",
193228
"category": "SwiftLint",
194229
"name": "Implicit Getter",
195230
"description": "Computed read-only properties should avoid using the get keyword.",
196231
"severity": "MINOR"
197232
},
233+
{
234+
"key": "implicitly_unwrapped_optional",
235+
"category": "SwiftLint",
236+
"name": "Implicitly Unwrapped Optional",
237+
"description": "Implicitly unwrapped optionals should be avoided when possible.",
238+
"severity": "MINOR"
239+
},
198240
{
199241
"key": "large_tuple",
200242
"category": "SwiftLint",
@@ -272,6 +314,13 @@
272314
"description": "Prefer Nimble operator overloads over free matcher functions.",
273315
"severity": "MINOR"
274316
},
317+
{
318+
"key": "notification_center_detachment",
319+
"category": "SwiftLint",
320+
"name": "Notification Center Detachment",
321+
"description": "An object should only remove itself as an observer in `deinit`.",
322+
"severity": "MINOR"
323+
},
275324
{
276325
"key": "number_separator",
277326
"category": "SwiftLint",
@@ -335,11 +384,18 @@
335384
"description": "Some methods should not call super",
336385
"severity": "MINOR"
337386
},
387+
{
388+
"key": "redundant_discardable_let",
389+
"category": "SwiftLint",
390+
"name": "Redundant Discardable Let",
391+
"description": "Prefer `_ = foo()` over `let _ = foo()` when discarding a result from a function.",
392+
"severity": "MINOR"
393+
},
338394
{
339395
"key": "redundant_nil_coalescing",
340396
"category": "SwiftLint",
341397
"name": "Redundant Nil Coalescing",
342-
"description": "nil coalescing operator is only evaluated if the lhs is nil , coalescing operator with nil as rhs is redundant",
398+
"description": "nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant",
343399
"severity": "MINOR"
344400
},
345401
{
@@ -465,7 +521,7 @@
465521
"key": "unused_enumerated",
466522
"category": "SwiftLint",
467523
"name": "Unused Enumerated",
468-
"description": "When the index is not used, .enumerated() can be removed.",
524+
"description": "When the index or the item is not used, `.enumerated()` can be removed.",
469525
"severity": "MINOR"
470526
},
471527
{
@@ -489,13 +545,6 @@
489545
"description": "@IBInspectable should be applied to variables only, have its type explicit and be of a supported type",
490546
"severity": "MINOR"
491547
},
492-
{
493-
"key": "variable_name",
494-
"category": "SwiftLint",
495-
"name": "Variable Name",
496-
"description": "Variable names 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. Variable names should not be too long or too short.",
497-
"severity": "CRITICAL"
498-
},
499548
{
500549
"key": "vertical_parameter_alignment",
501550
"category": "SwiftLint",

0 commit comments

Comments
 (0)