-
Notifications
You must be signed in to change notification settings - Fork 42
/
.swiftlint.yml
230 lines (225 loc) · 8.16 KB
/
.swiftlint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
included:
- Sources
- Tests
opt_in_rules:
- anyobject_protocol
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- convenience_type
- empty_collection_literal
- empty_count
- empty_string
- empty_xctest_method
- explicit_acl
- explicit_init
- fallthrough
- fatal_error_message
- file_name
- file_header
- file_types_order
- first_where
- force_unwrapping
- implicitly_unwrapped_optional
- joined_default_parameter
- last_where
- legacy_multiple
- let_var_whitespace
- literal_expression_end_indentation
- lower_acl_than_parent
- mark
- missing_docs
- modifier_order
- multiline_arguments
- multiline_arguments_brackets
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- multiline_parameters_brackets
- nimble_operator
- no_fallthrough_only
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- private_action
- private_outlet
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- single_test_class
- sorted_first_last
- sorted_imports
- strong_iboutlet
- switch_case_on_newline
# - trailing_closure
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- vertical_whitespace_between_cases
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- yoda_condition
- xct_specific_matcher
disabled_rules:
- trailing_whitespace
- line_length
- file_length
analyzer_rules:
- explicit_self
- unused_import
- unused_private_declaration
identifier_name:
excluded:
- id
number_separator:
minimum_length: 5
file_header:
required_pattern: |
\/\/
\/\/ SWIFTLINT_CURRENT_FILENAME
\/\/ SwiftyBot
\/\/
\/\/ The MIT License \(MIT\)
\/\/
\/\/ Copyright \(c\) 2016 - 2019 Fabrizio Brancati.
\/\/
\/\/ Permission is hereby granted, free of charge, to any person obtaining a copy
\/\/ of this software and associated documentation files \(the "Software"\), to deal
\/\/ in the Software without restriction, including without limitation the rights
\/\/ to use, copy, modify, merge, publish, distribute, sublicense, and\/or sell
\/\/ copies of the Software, and to permit persons to whom the Software is
\/\/ furnished to do so, subject to the following conditions:
\/\/
\/\/ The above copyright notice and this permission notice shall be included in all
\/\/ copies or substantial portions of the Software\.
\/\/
\/\/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\/\/ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\/\/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\. IN NO EVENT SHALL THE
\/\/ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\/\/ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\/\/ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\/\/ SOFTWARE\.
custom_rules:
comments_space:
included: ".*.swift"
name: "Space After Comment"
regex: "(^ *//\\w+)"
message: "There should be a space after //"
severity: warning
double_space:
include: "*.swift"
name: "Double space"
regex: "([a-z,A-Z] \\s+)"
message: "Double space between keywords"
match_kinds: keyword
severity: warning
empty_line_after_guard:
included: ".*.swift"
name: "Empty Line After Guard"
regex: "(^ *guard[ a-zA-Z0-9=?.\\(\\),><!]*\\{[ a-zA-Z0-9=?.\\(\\),><!]*\\}\n *(?!(?:return|guard))\\S+)"
message: "There should be an empty line after a guard"
severity: warning
empty_line_after_super:
included: ".*.swift"
name: "Empty Line After Super"
regex: "(^ *super\\.[ a-zA-Z0-9=?.\\(\\)\\{\\}:,><!]*\n *(?!(?:\\}|return))\\S+)"
message: "There should be an empty line after super"
severity: warning
hardcoded_credential:
included: ".*.swift"
name: "Credentials should not be hard-coded"
regex: 'let \s*(?:token|password|Token|Password)\s*= ".+"'
message: "Because it is easy to extract strings from a compiled application, credentials should never be hard-coded."
severity: warning
if_as_guard:
included: ".*.swift"
name: "If as Guard"
regex: '\n *if [^\{]+\{\s*(?:return|break|continue)[^\n]*\n *\}(?! *else)'
message: "Don't use an if statement to just return/break/continue – use guard for such cases instead."
severity: warning
ip_address:
included: ".*.swift"
name: "IP addresses should not be hardcoded"
regex: '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
message: "Hardcoding an IP address into source code is a bad idea"
severity: warning
late_force_unwrapping:
included: ".*.swift"
name: "Late Force Unwrapping"
regex: '\(\S+\?\.\S+\)!'
message: "Don't use ? first to force unwrap later – directly unwrap within the parantheses."
severity: warning
redundant_parentheses:
included: ".*.swift"
name: "Redundant Parentheses"
regex: '(if|guard) \(.*\) (else)? \{'
message: "Condition should not be enclosed within parentheses."
severity: warning
single_line_return:
included: ".*.swift"
name: "Single Line Return"
regex: '\.\S+ *\{(?: *return|[^\n\}]+ in return) [^\}]+\}'
message: "Remove the 'return' when returning from a single line closure."
severity: warning
unnecessary_case_break:
included: ".*.swift"
name: "Unnecessary Case Break"
regex: '(case |default)(?:[^\n\}]+\n){2,}\s*break *\n|\n *\n *break(?:\n *\n|\n *\})'
message: "Don't use break in switch cases – Swift breaks by default."
severity: warning
unnecessary_nil_assignment:
included: ".*.swift"
name: "Unnecessary Nil Assignment"
regex: 'var \S+\s*:\s*[^\s]+\?\s*=\s*nil'
message: "Don't assign nil as a value when defining an optional type – it's nil by default."
severity: warning
unnecessary_type:
included: ".*.swift"
name: "Unnecessary Type"
regex: "[ a-zA-Z0-9]*(?:let|var) [ a-zA-Z0-9]*: ([a-zA-Z0-9]*)[\\? ]*= \\1"
message: "Type Definition Not Needed"
severity: warning
upper_camel_case:
included: ".*.swift"
name: "Upper Camel Case"
regex: "$[^//](?:protocol|class|struct|enum) [a-z]+[a-zA-Z]*"
message: "Class, Struct and Enum names should be UpperCamelCase."
severity: warning
useless_if:
included: ".*.swift"
name: "Useless If"
regex: 'if[ (]*?(:?true|false)[ )]*?\{'
message: "`if` statements with conditions that are always false have the effect of making blocks of code non-functional."
severity: warning
vertical_whitespaces_around_mark:
included: ".*.swift"
name: "Vertical Whitespaces Around MARK:"
regex: '\/\/\s*MARK:[^\n]*(\n)(?!\s*\n)|(\n\n\n)[ \t]*\/\/\s*MARK:|[^\s{]\n[^\n\/]*\/\/\s*MARK:'
message: "Include a single vertical whitespace (empty line) before and after MARK: comments."
severity: warning
vertical_whitespace_opening_braces:
included: ".*.swift"
name: "Vertical Whitespace after Opening Braces"
regex: '[{(\[][ \t]*\n[ \t]*\n'
message: "Don't include vertical whitespace (empty line) after opening braces."
severity: warning
vertical_whitespace_closing_braces:
included: ".*.swift"
name: "Vertical Whitespace after Opening Braces"
regex: '[\}(\[][ \t]*\n[ \t]*\n\}'
message: "Don't include vertical whitespace (empty line) after closing braces."
severity: warning