forked from Carthage/Carthage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.swiftlint.yml
120 lines (112 loc) · 4.15 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
opt_in_rules:
- attributes
- closure_end_indentation
- closure_spacing
- empty_count
- explicit_init
- fatal_error_message
- file_header
- first_where
- implicitly_unwrapped_optional
- no_extension_access_modifier
- number_separator
- operator_usage_whitespace
- redundant_nil_coalescing
- switch_case_on_newline
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call
disabled_rules:
- redundant_string_enum_value
- superfluous_disable_command
included:
- Source
excluded:
- Carthage
line_length:
warning: 160
ignores_comments: true
ignores_function_declarations: true
file_length:
ignore_comment_only_lines: true
file_header:
required_pattern: ''
trailing_comma:
mandatory_comma: true
custom_rules:
closing_brace_whitespace:
included: ".*.swift"
regex: '(?:\n| {2,})\}\)? *\n *[^ \n\})\]]'
name: "Closing Brace Whitespace"
message: "Empty line required after closing curly braces if code with same indentation follows."
severity: warning
if_as_guard:
included: ".*.swift"
regex: '\n *if [^\{]+\{\s*(?:return|break|continue)[^\n]*\n *\}(?! *else)'
name: "If as Guard"
message: "Don't use an if statement to just return/break/continue – 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
missing_docs:
included: ".*.swift"
regex: '\n *(?!\/\/\/)(\/\/)?[^\n\/]*\n *(?:@\S+ )*(?:public|open)'
name: "Missing Docs"
message: "Types, properties and methods with public or open access level should be documented."
severity: warning
multiple_closure_params:
included: ".*.swift"
regex: '\} *\) *\{'
name: "Multiple Closure Params"
message: "Don't use multiple in-line closures – save one or more of them to variables instead."
severity: warning
single_line_return:
included: ".*.swift"
regex: '\.\S+ *\{(?: *return|[^\n\}]+ in return) [^\}]+\}'
name: "Single Line Return"
message: "Remove the 'return' when returning from a single line closure."
severity: warning
space_before_comment:
included: ".*.swift"
regex: '\n[ ]{0}[^\/ \n][^\n]*\n[ ]{0}\/\/|\n[ ]{4}[^\/ \n][^\n]*\n[ ]{4}\/\/|\n[ ]{8}[^\/ \n][^\n]*\n[ ]{8}\/\/|\n[ ]{16}[^\/ \n][^\n]*\n[ ]{16}\/\/|\n[ ]{20}[^\/ \n][^\n]*\n[ ]{20}\/\/|\n[ ]{24}[^\/ \n][^\n]*\n[ ]{24}\/\/'
name: "Space Before Comment"
message: "Always put a space line before a comment line and always comment code beforehand."
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_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 after MARK: comments."
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