-
Notifications
You must be signed in to change notification settings - Fork 16
/
.swiftlint.yml
210 lines (203 loc) · 5.9 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
# Allowing no_fallthrough_only (which is enabled by default) can cause a crash:
disabled_rules:
- no_fallthrough_only
opt_in_rules:
- anyobject_protocol
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- contains_over_first_not_nil
- convenience_type
- discouraged_object_literal
- empty_count
- empty_string
- empty_xctest_method
- explicit_enum_raw_value
- explicit_init
- explicit_top_level_acl
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_header
- first_where
- force_unwrapping
- implicit_return
- implicitly_unwrapped_optional
- joined_default_parameter
- let_var_whitespace
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- multiline_arguments
- multiline_function_chains
- multiline_parameters
- nimble_operator
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prefixed_toplevel_constant
- private_action
- private_outlet
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- redundant_nil_coalescing
- redundant_type_annotation
- required_enum_case
- single_test_class
- sorted_first_last
- sorted_imports
- switch_case_on_newline
- trailing_closure
- unavailable_function
- unneeded_parentheses_in_closure_argument
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- yoda_condition
# NOT opted in:
# - discouraged_optional_boolean
# - discouraged_optional_collection
# - explicit_acl
# - explicit_type_interface
# - file_name
# - function_default_parameter_at_end
# - missing_docs
# - no_extension_access_modifier
# - no_grouping_extension
# - strict_fileprivate
included:
- Examples
- Sources
- Tests
excluded:
- Examples/XestiMonitorsDemo-iOS/Pods
- Examples/XestiMonitorsDemo-tvOS/Pods
reporter: "xcode"
attributes:
always_on_line_above:
- "@objc"
always_on_same_line:
- "@IBAction"
- "@IBOutlet"
colon:
apply_to_dictionaries: true
flexible_right_spacing: false
cyclomatic_complexity:
warning: 10
error: 20
ignores_case_statements: true
dynamic_inline: warning
empty_count: warning
file_length:
warning: 400
error: 500
ignore_comment_only_lines: true
function_body_length:
warning: 100
error: 200
function_parameter_count:
warning: 5
error: 8
identifier_name:
max_length: 50
min_length: 1
large_tuple:
warning: 3
error: 4
line_length:
warning: 150
ignores_comments: true
ignores_function_declarations: false
ignores_urls: true
multiline_arguments:
first_argument_location: same_line
nesting:
statement_level: 5
type_level: 2
number_separator:
minimum_length: 0
object_literal:
color_literal: true
image_literal: true
private_outlet:
allow_private_set: false
private_over_fileprivate:
validate_extensions: true
shorthand_operator: warning
superfluous_disable_command: warning
trailing_comma:
mandatory_comma: false
trailing_whitespace:
ignores_comments: false
ignores_empty_lines: false
type_body_length:
warning: 200
error: 300
type_name:
max_length: 50
unused_optional_binding:
ignore_optional_try: false
vertical_whitespace:
max_empty_lines: 1
custom_rules:
closing_brace_whitespace:
regex: '(?:\n| {2,})\}\)? *\n *[^ \n\})\]#]'
name: "Closing Brace Whitespace"
message: "Empty line required after closing curly braces if code with same indentation follows."
severity: warning
empty_line_after_opening_brace:
regex: '\{[^\n}]*\n\s*\n(?!\s*\/\/\s*MARK:)'
name: "Empty Line After Opening Brace"
message: "Don't put an empty line after an opening curly brace."
severity: warning
empty_line_before_closing_brace:
regex: '\n\s*\n\s*\}'
name: "Empty Line Before Closing Brace"
message: "Don't put an empty line before a closing curly brace."
severity: warning
late_force_unwrapping:
regex: '\(\S+\?\.\S+\)!'
name: "Late Force Unwrapping"
message: "Don't use ? first to force unwrap later – directly unwrap within the parantheses."
severity: warning
multiple_closure_params:
regex: '\} *\) *\{'
name: "Multiple Closure Params"
message: "Don't use multiple in-line closures – save one or more of them to variables instead."
severity: warning
single_line_return:
regex: '\.\S+ *\{(?: *return|[^\n\}]+ in return) [^\}]+\}'
name: "Single Line Return"
message: "Remove the 'return' when returning from a single line closure."
severity: warning
space_before_comment:
regex: '\n[ ]{0}[^\/ \n#][^\n]*\n[ ]{0}\/\/|\n[ ]{4}[^\/ \n#][^\n]*\n[ ]{4}\/\/|\n[ ]{8}[^\/ \n#][^\n]*\n[ ]{8}\/\/|\n[ ]{16}[^\/ \n#][^\n]*\n[ ]{16}\/\/|\n[ ]{20}[^\/ \n#][^\n]*\n[ ]{20}\/\/|\n[ ]{24}[^\/ \n#][^\n]*\n[ ]{24}\/\/'
name: "Space Before Comment"
message: "Always put a space line before a comment line and always comment code beforehand."
severity: warning
unnecessary_case_break:
regex: '(case |default)(?:[^\n\}]+\n){2,}\s*break *\n|\n *\n *break(?:\n *\n|\n *\})'
name: "Unnecessary Case Break"
message: "Don't use break in switch cases – Swift breaks by default."
severity: warning
unnecessary_nil_assignment:
regex: 'var \S+\s*:\s*[^\s]+\?\s*=\s*nil'
name: "Unnecessary Nil Assignment"
message: "Don't assign nil as a value when defining an optional type – it's nil by default."
severity: warning
vertical_whitespaces_around_mark:
regex: '\/\/\s*MARK:[^\n]*(\n)(?!\n)|(\n\n\n)[ \t]*\/\/\s*MARK:|[^\s{]\n[^\n\/]*\/\/\s*MARK:'
name: "Vertical Whitespaces Around MARK:"
message: "Include a single vertical whitespace (empty line) before and after MARK: comments."
severity: warning
whitespace_comment_start:
regex: '[^:#][^:#]\/\/[^\s\/]'
name: "Whitespace Comment Start"
message: "A comment should always start with a whitespace."
severity: warning