-
Notifications
You must be signed in to change notification settings - Fork 99
/
.swiftlint.yml
192 lines (164 loc) · 6.79 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
# MEGA Lint Rules Configuration
# Custom Rules
custom_rules:
discouraged_path_extension:
regex: 'URL\(fileURLWithPath: [a-zA-Z0-9\$\(\)\.]*\).pathExtension'
name: "Discouraged use of getting path extension with URL.init"
message: "Using URL(fileURLWithPath:) to get a string pathExtension might cause the app to crash. Use MEGASwift.String.pathExtension instead."
discouraged_last_path_component:
regex: 'URL\(fileURLWithPath: [a-zA-Z0-9\$\(\)\.]*\).lastPathComponent'
name: "Discouraged use of getting last path component with URL.init"
message: "Using URL(fileURLWithPath:) to get a string lastPathComponent might cause the app to crash. Use MEGASwift.String.lastPathComponent instead."
disallow_MEGASdkManager:
regex: 'MEGASdkManager'
name: "Disallow MEGASdkManager"
message: "'MEGASdkManager' is deprecated, use an instance of 'MEGASdk+SharedInstance' or 'MEGASdk+SharedInstanceWrapper' instead"
disallow_MEGAGenericRequestDelegate:
regex: 'MEGAGenericRequestDelegate'
name: "Disallow MEGAGenericRequestDelegate"
message: "'MEGAGenericRequestDelegate' is deprecated, use 'RequestDelegate' instead"
disallow_MEGAResultRequestDelegate:
regex: 'MEGAResultRequestDelegate'
name: "Disallow MEGAResultRequestDelegate"
message: "'MEGAResultRequestDelegate' is deprecated, use 'RequestDelegate' instead"
disallow_MEGAChatGenericRequestDelegate:
regex: 'MEGAChatGenericRequestDelegate'
name: "Disallow MEGAChatGenericRequestDelegate"
message: "'MEGAChatGenericRequestDelegate' is deprecated, use 'ChatRequestDelegate' instead"
disallow_MEGAChatResultRequestDelegate:
regex: 'MEGAChatResultRequestDelegate'
name: "Disallow MEGAChatResultRequestDelegate"
message: "'MEGAChatResultRequestDelegate' is deprecated, use 'ChatRequestDelegate' instead"
avoid_empty_lines_at_the_top_of_the_file:
regex: '\A[\r\n]+'
name: "Avoid empty lines at the top of the file"
message: "No empty lines are allowed at the top of the file"
# Currently we use `only_rules` so that we can validate each and every default rule.
# Once everything has been set, we can start using the `disabled_rules` and `opt_in_rules`.
only_rules:
# SwiftLint Default Rules
# Can be enabled right away (0 issues)
- blanket_disable_command
- block_based_kvo
- deployment_target
- duplicate_conditions
- duplicate_enum_cases
- duplicated_key_in_dictionary_literal
- dynamic_inline
- empty_parameters
- generic_type_name
- invalid_swiftlint_command
- legacy_cggeometry_functions
- legacy_constant
- legacy_hashing
- legacy_nsgeometry_functions
- legacy_random
- no_fallthrough_only
- nsobject_prefer_isequal
- orphaned_doc_comment
- private_unit_test
- protocol_property_accessors_order
- redundant_set_access_control
- redundant_string_enum_value
- self_in_property_initialization
- superfluous_disable_command
- unavailable_condition
- unused_control_flow_label
- valid_ibinspectable
- computed_accessors_order
- is_disjoint
- reduce_boolean
- redundant_objc_attribute
- todo
- unused_enumerated
- unused_optional_binding
- unused_setter_value
- duplicate_imports
- switch_case_alignment
- unneeded_break_in_switch
- empty_enum_arguments
- unused_closure_parameter
- closure_parameter_position
- empty_parentheses_with_trailing_closure
- multiple_closures_with_trailing_closure
- operator_whitespace
- redundant_discardable_let
- legacy_constructor
- shorthand_operator
- ns_number_init_as_function_reference
- return_arrow_whitespace
- closing_brace
- void_return
- for_where
- trailing_semicolon
- trailing_newline
- implicit_getter
- redundant_void_return
- syntactic_sugar
- statement_position
- custom_rules
- no_space_in_method_call
- redundant_optional_initialization
- control_statement
- vertical_parameter_alignment
- private_over_fileprivate
- comma
- trailing_comma
- mark
- opening_brace
- vertical_whitespace
- colon
- comment_spacing
- xctfail_message
- sorted_imports
- cyclomatic_complexity
# Complex fixes or a ton of issues (>100 issues)
# - type_name (91 issues) - complex because we need to rename stuff
# Not sure if we should implement
# - class_delegate_protocol (4 issues)
# - compiler_protocol_init (3 issues)
# - discouraged_direct_init (2 issues)
# Using `UIDevice()` directly is discouraged, but we're currently using it to check whether or not the device is an iPad by doing this `UIDevice().iPadDevice`
# - force_cast
# - force_try (2 issues)
# I think both force try and force casting is OK at some cases, as long as we're using it appropriately and not abusing it
# - inclusive_language (2 issues)
# - nesting (14 issues)
# - notification_center_detachment (5 issues)
# - void_function_in_ternary (13 issues)
# This is something that has been discussed and I need to know you guys' opinions on the rule.
# Should be implemented, but not sure about how much the config values should be
# - large_tuple (14 issues, max 2 members)
# - file_length (40 issues, max 400 lines)
# - type_body_length (47 issues, max 250 lines)
# - function_body_length (43 issues, max 50 lines)
# - function_parameter_count (68 issues, max 5 parameters)
# - line_length (4202 issues, max of 120 characters)
# We don't want to implement (not necessary, I think)
# - trailing_whitespace (17200 issues, mindblown)
# - leading_whitespace (398 issues)
# - identifier_name (427 issues)
# Rule Configurations
cyclomatic_complexity:
warning: 15
error: 30
ignores_case_statements: true
# Path Configurations
included: # Paths to include during linting. `--path` is ignored if present.
- iMEGA
- MEGAData
- MEGADomain
- MEGADataTests
- MEGADomainTests
- MEGAUnitTests
- Modules
excluded: # Paths to ignore during linting. Takes precedence over `included`.
- Modules/Localization/MEGAL10n/Sources/MEGAL10n/Strings+Generated.swift
- Modules/Localization/MEGAL10n/SwiftGen
- SwiftGen
- transifex
- Xcode Templates
# Excluded temporarily because it is low priority but requires changes in the SDK git project, which needed to be merged by the SDK team
- Modules/DataSource/MEGASDK/Sources/MEGASDK/examples
allow_zero_lintable_files: false
reporter: "xcode"