-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
175 lines (158 loc) · 4.58 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
disabled_rules: # rule identifiers to exclude from running
- line_length
- identifier_name
- trailing_whitespace
- todo
- function_body_length
- file_length
- pattern_matching_keywords
opt_in_rules: # some rules are only opt-in
- empty_count
- attributes
- array_init
- closure_body_length
- closure_end_indentation
- closure_spacing
- collection_alignment
- conditional_returns_on_newline
- contains_over_first_not_nil
- convenience_type
- discouraged_object_literal
- empty_string
- empty_xctest_method
#- explicit_acl
- explicit_init
- fatal_error_message
- first_where
- force_unwrapping
- identical_operands
- legacy_random
- modifier_order
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- private_outlet
- private_action
- prohibited_super_call
- redundant_nil_coalescing
- redundant_type_annotation
- single_test_class
- sorted_first_last
- static_operator
- switch_case_on_newline
- toggle_bool
- trailing_closure
- untyped_error_in_catch
- unused_import
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
- Model/DataModels
- ThirdPartyFrameworks
# analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
# - explicit_self
# # configurable rules can be customized from this configuration file
# # binary rules can set their severity level
# force_cast: warning # implicitly
# force_try:
# severity: warning # explicitly
# # rules that have both warning and error levels, can set just the warning level
# # implicitly
# line_length: 110
# # they can set both implicitly with an array
# type_body_length:
# - 300 # warning
# - 400 # error
# # or they can set both explicitly
# file_length:
# warning: 500
# error: 1200
# # naming rules can set warnings/errors for min_length and max_length
# # additionally they can set excluded names
# type_name:
# min_length: 4 # only warning
# max_length: # warning and error
# warning: 40
# error: 50
# excluded: iPhone # excluded via string
# identifier_name:
# min_length: # only min_length
# error: 4 # only error
# excluded: # excluded via string array
# - id
# - URL
# - GlobalAPIKey
cyclomatic_complexity: 25
function_parameter_count: 6
closure_body_length: 120
nesting:
type_level:
warning: 2
statement_level:
warning: 10
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube)
custom_rules:
image_name_initialization: # Disable UIImage init from name
included: ".*.swift"
name: "Image initialization"
regex: 'UIImage\(named:[^)]+\)'
message: "Use R.image.name() or typealiaas of this instead"
severity: warning
open_iboutlets:
included: ".*.swift"
name: "IBOutlet opening"
regex: '@IBOutlet ?(weak){0,1} var'
message: "IBOutlet should be private"
severity: error
open_ibaction:
included: ".*.swift"
name: "IBAction opening"
regex: '@IBAction func'
message: "IBAction should be private"
severity: error
mark_newlines:
included: ".*.swift"
name: "MARK newlines surrounding"
regex: '(([}{)\w \t]+\n{1}[ \t]*)(\/\/ MARK: - [\w ]*))|((\/\/ MARK: - [\w ]*)(\n{1}[ \t]*\w+))'
message: "Every MARK should be surrounded with 1 newline before and 1 after it"
severity: warning
unnecessary_type:
name: "Unnecessary Type"
regex: '(?sm)[ \ta-zA-Z0-9]?(?:let|var){1} [ \ta-zA-Z0-9]+?:[ \t]+?([a-zA-Z0-9]+?)[\t ]+?=[\t ]?\1'
message: "Type Definition Not Needed"
severity: warning
comments_space:
name: "Space After Comment"
regex: '(^ *//\w+)'
message: "There should be a space after //"
severity: warning
empty_closure_params:
included: ".*.swift"
name: "Empty closure params"
regex: '\{ (\(\) -> Void in)$'
message: "`() -> Void in` should be avoided"
severity: warning
unnecessary_type:
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: error
final_class:
included: ".*.swift"
name: "Final class requrement"
regex: '^class'
message: "All classes must be final or nonfinal"
saverity: error
numbers_smell:
regex: '(return |case |\w\(|: |\?\? |\, |== |<=? |>=? |\+= |\-= |\/= |\*= |%= |\w\.\w+ = )\(*\d{2,}'
message: "Numbers smell; define a constant instead."
print_using:
regex: 'print'
message: "Print decrease performance of the app"
class_protocol:
regex: ': class'
message: "Use Anyobject instead"
foundation_using:
regex: 'import Foundation'
message: "Do you really need for Foundation ???"