-
Notifications
You must be signed in to change notification settings - Fork 13
/
.swiftlint.yml
103 lines (91 loc) · 5.3 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
# refs: https://github.com/realm/SwiftLint/blob/master/Rules.md
reporter: "xcode"
included:
- Sources
- Demo
excluded:
- Demo/Pods
disabled_rules:
- cyclomatic_complexity # Complexity of function bodies should be limited.
- file_length # Files should not span too many lines.
- for_where # where clauses are preferred over a single if inside a for.
- force_cast # Force casts should be avoided.
- force_try # Force tries should be avoided.
- function_body_length # Functions bodies should not span too many lines.
- line_length # Lines should not span too many characters.
- todo # TODOs and FIXMEs should be resolved.
- trailing_whitespace # Lines should not have trailing whitespace.
- unused_setter_value # Setter value is not used.
- multiple_closures_with_trailing_closure # Trailing closure syntax should not be used when passing more than one closure argument.
opt_in_rules:
- anyobject_protocol # Prefer using `AnyObject` over class for class-only protocols.
- array_init # Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.
- closure_end_indentation # Closure end should have the same indentation as the line that started it.
- closure_spacing # Closure expressions should have a single space inside each brace.
- collection_alignment # All elements in a collection literal should be vertically aligned
- contains_over_filter_count # Prefer `contains` over comparing `filter(where:).count` to `0`.
- contains_over_filter_is_empty # Prefer `contains` over using `filter(where:).isEmpty`
- contains_over_first_not_nil # Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`.
- contains_over_range_nil_comparison # Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`.
- discouraged_object_literal # Prefer initializers over object literals.
- empty_collection_literal # Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal.
- empty_count # Prefer checking `isEmpty` over comparing count to zero.
- empty_string # Prefer checking `isEmpty` over comparing string to an empty string literal.
- empty_xctest_method # Empty `XCTest` method should be avoided.
- explicit_init # Explicitly calling `.init()` should be avoided.
- fallthrough # Fallthrough should be avoided.
- fatal_error_message # A `fatalError` call should have a message.
- file_header # Header comments should be consistent with project patterns.
- first_where # Prefer using `.first(where:)` over `.filter { }.first` in collections.
- flatmap_over_map_reduce # Prefer `flatMap` over `map` followed by `reduce([], +)`.
- function_default_parameter_at_end # Prefer to locate parameters with defaults toward the end of the parameter list.
- legacy_multiple # Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`).
- joined_default_parameter # Discouraged explicit usage of the default. separator.
- last_where # Prefer using `.last(where:)` over `.filter { }.last` in collections.
- legacy_random # Prefer using `type.random(in:)` over legacy functions.
- literal_expression_end_indentation # Array and dictionary literal end should have the same indentation as the line that started it.
- lower_acl_than_parent # Ensure definitions have a lower access control level than their enclosing parent.
- multiline_literal_brackets # Multiline literals should have their surrounding brackets in a new line.
- prohibited_super_call # Some methods should not call super.
- redundant_type_annotation # Variables should not have redundant type annotation
- toggle_bool # Prefer `someBool.toggle()` over `someBool = !someBool`.
- unneeded_parentheses_in_closure_argument # Parentheses are not needed when declaring closure arguments.
- unused_import # All imported modules should be required to make the file compile.
- unused_private_declaration # Private declarations should be referenced in that file.
- vertical_parameter_alignment_on_call # Function parameters should be aligned vertically if they're in multiple lines in a method call.
custom_rules:
trailing_logical_operator:
name: 'Trailing logical operator'
message: 'Leading logical operator should move to trailing.'
regex: '^[\s]*(\|\||&&)'
function_parameter_count:
warning: 11
error: 11
# Identifier names should only contain alphanumeric characters and start with a lowercase character or should only contain capital letters.
# In an exception to the above, variable names may start with a capital letter when they are declared static and immutable. Variable names should not be too long or too short.
identifier_name:
allowed_symbols: ['_']
max_length:
warning: 50
error: 50
min_length:
warning: 1
error: 1
validates_start_with_lowercase: false
# Types should be nested at most 2 level deep, and statements should be nested at most 5 levels deep.
nesting:
type_level:
warning: 2
error: 2
# Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 50 characters in length.
type_name:
allowed_symbols: ['_']
max_length:
warning: 50
error: 50
# Limit vertical whitespace to a single empty line.
vertical_whitespace:
max_empty_lines: 2
# Forbid "Created by" line in file header
file_header:
forbidden_pattern: \b(Created by)\b