-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.swiftlint.yml
139 lines (125 loc) · 3.43 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
# The default ruleset for our projects.
#
# If a config file is found in the repository you are running the tooling against,
# this will be overriden with that repo's config file
excluded:
- ${PWD}/.build
reporter: xcode
disabled_rules:
- statement_position
- trailing_comma
- opening_brace
- unused_setter_value
- type_name
# This one I'd like some more customization on, specifically only disable it for test classes
- type_body_length
- todo
- syntactic_sugar
opt_in_rules:
- force_unwrapping
- discouraged_assert
- enum_case_associated_values_count
- explicit_init
- redundant_type_annotation
- unused_import
- missing_docs
- expiring_todo
- xct_specific_matcher
trailing_whitespace:
ignores_empty_lines: true
switch_case_alignment:
indented_cases: true
line_length:
warning: 140
ignores_comments: true
ignores_interpolated_strings: true
identifier_name:
excluded:
- id
- ID
- op
- ws
- db
function_body_length: 60
file_length:
ignore_comment_only_lines: true
force_unwrapping:
severity: error
nesting:
type_level: 3
cyclomatic_complexity:
ignores_case_statements: true
custom_rules:
logger_over_print:
name: "Raw print"
regex: "\\b(print\\()"
excluded: ".*\/main\\.swift"
capture_group: 0
message: "Prefer logger usage over raw prints"
severity: error
# by default we match anything that isn't a comment or raw string
match_kinds: &ignore_comments
- argument
- attribute.builtin
- attribute.id
- buildconfig.id
- buildconfig.keyword
- identifier
- keyword
- number
- objectliteral
- parameter
- placeholder
- string_interpolation_anchor
- typeidentifier
string_to_data:
name: "Unsafe String to Data"
regex: "\\s*(\\.data\\(using: \\.utf8\\))"
capture_group: 0
message: "Use Data(myString.utf8) instead"
severity: error
match_kinds: *ignore_comments
public_in_test:
name: "Public In Test"
included: ".*\\/Tests\\/.*\\.swift"
regex: "(public )"
match_kinds: *ignore_comments
message: "public identifier should not be used in test targets"
severity: error
non_final_test_class:
name: "Non-Final Test Class"
regex: "^(\\w*\\s?(?<!final )(?<!open )class \\w*: XCTestCase \\{$)"
message: "XCTestCase classes should be final"
severity: error
match_kinds: *ignore_comments
no_fatalerror:
name: "Unnecessary fatalError"
regex: "\\b(fatalError\\()"
excluded: ".*\/main\\.swift"
capture_group: 0
message: "fatalError kills the executable. Use a throwing function instead."
severity: error
match_kinds: *ignore_comments
no_precondition:
name: "Unnecessary precondition"
regex: "\\b(precondition\\()"
capture_group: 0
message: "precondition kills the executable. Use a throwing function instead."
severity: error
match_kinds: *ignore_comments
no_exit:
name: "Unnecessary exit"
regex: "\\b(exit\\()"
excluded: ".*\/main\\.swift"
capture_group: 0
message: "exit... exits the executable. Use a throwing function instead."
severity: error
match_kinds: *ignore_comments
testable_import:
name: "@testable outside Test"
excluded: ".*\\/Tests\\/.*\\.swift"
regex: "(@testable import)"
capture_group: 0
message: "@testable should not be used outside of test modules"
severity: error
match_kinds: *ignore_comments