-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
195 lines (168 loc) · 4.93 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
disabled_rules:
- inclusive_language
opt_in_rules:
- force_unwrapping
- vertical_whitespace_between_cases
- empty_count
- unused_optional_binding
- implicit_return
- missing_docs
identifier_name:
excluded:
- i
- j
- x
- y
- z
- to
- id
type_name:
excluded:
- T
included:
- Turing
- LocalPods
excluded:
- Pods
warning_threshold: 3
line_length:
warning: 120
error: 120
ignores_urls: true
ignores_comments: true
force_unwrapping:
error
force_cast:
error
unused_optional_binding:
error
cyclomatic_complexity:
warning: 12
# Custom rules
custom_rules:
cyrillic_file_name:
name: "Usage of cyrillic in file naming is forbidden"
regex: "[A-Za-z]*[ЁёА-я]+[A-Za-z]*(\\.swift)$"
message: "Ensure that filename does not contain cyrillic symbols"
match_kinds:
- comment
severity: error
cyrillic_code:
name: "Usage of cyrillic in code is forbidden"
regex: "[ЁёА-я]"
message: "Ensure that your code does not contain cyrillic symbols"
match_kinds:
- argument
- identifier
- keyword
- parameter
- typeidentifier
- comment
- doccomment
severity: error
wrong_id_usage:
name: "Wrong identificator naming"
excluded: "path/to/DTO"
regex: "(var|let) \\w*Id( |:)"
message: "Use `ID` instead"
severity: error
wrong_url_usage:
name: "Wrong URL naming"
excluded: "path/to/DTO"
regex: "(var|let) \\w*Url( |:)"
message: "Use `URL` instead"
severity: error
empty_string_check:
name: "Incorrect empty string checking"
regex: "( == \"\")|(== \"\")|( ==\"\")|(==\"\")|( != \"\")|(!= \"\")|( !=\"\")|(!=\"\")"
message: "Use `string.isEmpty` instead"
severity: warning
guard_self_usage:
name: "Wrong guard let self = self usage"
regex: "guard\\s+let\\s+(((?!self).)\\S* = self[ ,]|`self` = self)"
message: "Use `guard let self = self` instead"
severity: error
empty_array_constructor:
name: "Wrong empty array constructor"
regex: "(var|let) \\w* = \\[\\w*\\]\\(\\)"
message: "Use `var array: [Type] = []` instead"
severity: warning
boolean_redundant_condition:
name: "Bool optional chaining is forbidden"
regex: "(?? true)|(?? false)"
message: "Use `== true` or `== false` instead"
severity: error
boolean_clear_condition:
name: "Overcomplicated condition"
regex: "^(?>(?!(as\\?)|(\\?.)).)*((!= true)|(!= false)).*$"
message: "Use `== true` or `== false` or variable as condition"
severity: warning
documentation_ticks:
name: "Incorrect apostrophe in the documentation"
regex: "´"
message: "Use '`' instead of '´' for correct work of documentation"
match_kinds:
- comment
- doccomment
severity: error
boolean_in_ternar_return:
name: "Returning Bool from ternary expression"
regex: "\\? (true : false)|(false : true)"
message: "Do not use ternary expression for returning Bool"
severity: warning
unowned:
name: "Usage of unowned is forbidden"
regex: "\\[unowned "
message: "Use `weak` instead of `unowned`"
severity: error
type_inferred_context:
name: "Unnecessary type indication"
regex: "^\\w* *((var)|(let)) \\w+\\:\\s(\\w+)\\s\\=\\s\\4"
message: "Use `var a = Type()` instead"
severity: warning
handler_names:
name: "The closure name does not contain the Handler suffix"
regex: "(var|let) \\w+(Action|Block): (\\(|\\w+(Action|Handler))"
message: "The closure must have the Handler suffix"
severity: warninig
forced_handlers:
name: "Force unwrapping for closures is forbidden"
regex: "(var|let) \\w+: (\\(*\\w*\\)->\\(\\w*\\)*|\\w+(Action|Handler))!"
message: "Use `var handler: Handler?` instead of `var handler: Handler!`"
severity: error
color_literal:
name: "Color literals are forbidden"
regex: "#colorLiteral"
message: "Use the ready-made colors added to the app"
severity: error
objc_inline:
name: "Wrong @objc syntax"
regex: "@objc\\n"
message: "Use oneline @objc syntax"
severity: error
texts:
name: "Hardcode for text in Presentation is forbidden"
included: "path/to/Presentation"
regex: "\"[a-zA-Zа-яА-Я]"
message: "Use Texts structure"
match_kinds:
- string
severity: error
void_parameters_method:
name: "Usage of methods for creating a View without parameters is prohibited"
regex: "\\(\\) -> some View \\{"
message: "Use variable instead of method"
severity: error
protocol_naming:
name: "Protocol name must start with `I` prefix"
regex: "protocol ((?![I])\\w|I )"
message: "Add `I` prefix"
match_kinds:
- identifier
- keyword
severity: error
view_controller_naming:
name: "UIViewController name must have `ViewController` suffix"
regex: "(class) (\\w+)(?<!(ViewController)|(Self))(:| =) UIViewController"
message: "Add `ViewController` suffix"
severity: error