forked from FlineDev/BartyCrouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
167 lines (160 loc) · 6.11 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
opt_in_rules:
- attributes
- closure_end_indentation
- closure_spacing
- empty_count
- explicit_init
- file_header
- first_where
- let_var_whitespace
- nimble_operator
- no_extension_access_modifier
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- private_outlet
- prohibited_super_call
- redundant_nil_coalescing
- sorted_imports
- switch_case_on_newline
- trailing_closure
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call
disabled_rules:
- todo
- cyclomatic_complexity
- type_body_length
included:
- Sources
- Tests
excluded:
- Carthage
- Package.swift
- UsageExamples.playground
- Tests/Assets
identifier_name:
excluded:
- id
line_length: 160
file_header:
required_pattern: |
\/\/
\/\/ Created by [^\(\)\d\n]+ on \S{6,10}\.
\/\/ Copyright © \d{4} Flinesoft\. All rights reserved\.
\/\/
custom_rules:
closing_brace_whitespace:
included: ".*.swift"
regex: '(?:\n| {2,})\}\)? *\n *[^ \n\})\]s]'
name: "Closing Brace Whitespace"
message: "Empty line required after closing curly braces if code with same indentation follows."
severity: warning
closure_params_parantheses:
included: ".*.swift"
regex: '\{\s*\([^):]+\)\s*in'
name: "Unnecessary Closure Params Parantheses"
message: "Don't use parantheses around non-typed parameters in a closure."
severity: warning
if_as_guard:
included: ".*.swift"
regex: '\n *if [^\{]+\{\s*return\s*(?:nil){0,1}([^a-zA-z\n]*)\n*\s*\}(?! *else)'
name: "If as Guard"
message: "Don't use an if statement to just return – use guard for such cases instead."
severity: warning
late_force_unwrapping:
included: ".*.swift"
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:
included: ".*.swift"
regex: '\n *(?:[^\.\n=]+\.)+[^\(\s]+\([^\{\n]+\{[^\}\n]+\}\)\s*\{'
name: "Multiple Closure Params"
message: "Don't use multiple in-line closures – save one or more of them to variables instead."
severity: warning
none_case_enum:
included: ".*.swift"
regex: 'enum\s+[^\{]+\{(?:\s*\/\/[^\n]*)*(?:\s*case\s+[^\n]+)*\s*case\s+none[^\S]'
name: "Non Case Enum"
message: "Do not call enum cases `none` as you might run into problems with Optionals of this type."
severity: warning
quick_temporary_disabling:
included: ".*.swift"
regex: '\sxdescribe\(|\sxcontext\(|\sxit\('
name: "Quick Temporary Disabling"
message: "Temporary disabled Quick examples or groups shouldn't be commited."
severity: warning
quick_temporary_focus:
included: ".*.swift"
regex: '\sfdescribe\(|\sfcontext\(|\sfit\('
name: "Quick Temporary Focus"
message: "Temporary focused Quick examples or groups shouldn't be commited."
severity: warning
single_line_enum_cases:
included: ".*.swift"
regex: 'enum [^\{]+\{\s*(?:\s*\/\/[^\n]*)*\s*case\s+[^,(\n]+,'
name: "Single Line Enum Cases"
message: "Use a new line for each enum case."
severity: warning
single_line_guard:
included: ".*.swift"
regex: 'guard[^\{]{2,80}else\s*\{\s*\n\s*return.{2,40}\}'
name: "Single Line Guard"
message: "Use a single line guard for simple checks."
severity: warning
too_much_indentation:
included: ".*.swift"
regex: '\n {0}[^\s\/][^\n]*[^,|&]\n+ {5,}\S|\n {4}[^\s\/][^\n]*[^,|&]\n+ {9,}\S|\n {8}[^\s\/][^\n]*[^,|&]\n+ {13,}\S|\n {12}[^\s\/][^\n]*[^,|&]\n+ {17,}\S|\n {16}[^\s\/][^\n]*[^,|&]\n+ {21,}\S|\n {20}[^\s\/][^\n]*[^,|&]\n+ {25,}\S'
name: "Too Much Indentation"
message: "Don't indent code by more than 4 whitespaces."
severity: warning
too_much_unindentation:
included: ".*.swift"
regex: ' {28}[^\s\.](.|[^\n]*[^\)][^\ ][^\}])\n+ {0,23}[^\s\/]| {24}[^\s\.](.|[^\n]*[^\)][^\ ][^\}])\n+ {0,19}[^\s\/]| {20}[^\s\.](.|[^\n]*[^\)][^\ ][^\}])\n+ {0,15}[^\s\/]| {16}[^\s\.](.|[^\n]*[^\)][^\ ][^\}])\n+ {0,11}[^\s\/]| {12}[^\s\.](.|[^\n]*[^\)][^\ ][^\}])\n+ {0,7}[^\s\/]| {8}[^\s\.](.|[^\n]*[^\)][^\ ][^\}])\n+ {0,3}[^\s\/]'
name: "Too Much Unindentation"
message: "Don't unindent code by more than 4 whitespaces."
severity: warning
unnecessary_case_break:
included: ".*.swift"
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:
included: ".*.swift"
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_whitespace_between_cases:
included: ".*.swift"
regex: '[^\n{][ \t]*\n[ \t]*(?:case[^\n]+|default):[ \t]*\n'
name: "Vertical Whitespace Between Cases"
message: "Include a vertical whitespace (empty line) between cases in switch statements."
severity: warning
vertical_whitespaces_around_mark:
included: ".*.swift"
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 none after MARK: comments."
severity: warning
vertical_whitespace_opening_braces:
included: ".*.swift"
regex: '[{(\[][ \t]*\n[ \t]*\n'
name: "Vertical Whitespace after Opening Braces"
message: "Don't include vertical whitespace (empty line) after opening braces."
severity: warning
vertical_whitespace_closing_braces:
included: ".*.swift"
regex: '\n[ \t]*\n[ \t]*[)}\]]'
name: "Vertical Whitespace before Closing Braces"
message: "Don't include vertical whitespace (empty line) before closing braces."
severity: warning
whitespace_comment_start:
included: ".*.swift"
regex: '[^:#][^:#]\/\/[^\s\/]'
name: "Whitespace Comment Start"
message: "A comment should always start with a whitespace."
severity: warning