-
Notifications
You must be signed in to change notification settings - Fork 0
/
swiftlint.yml
92 lines (76 loc) · 3.32 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
# swiftlint.yml
# Define which files and directories to include or exclude
included:
- . # Include all directories and files
excluded:
- Pods # Ignore generated files from dependencies
- Carthage
- .build # Ignore build artifacts
- Generated # Ignore auto-generated code
- Source/ExcludedDirectory
# Disable rules that are too strict or unnecessary for your project
disabled_rules:
- force_cast # Avoid force casting; use safer alternatives
- force_try # Avoid force-try; handle errors explicitly
- file_length # Disable file length warnings if you have large files
- trailing_whitespace # Disable trailing whitespace warnings
- line_length # Disable line length warnings (configure separately)
# Opt-in rules to enforce more strict coding standards
opt_in_rules:
- closure_spacing # Enforces spacing around closures
- contains_over_filter_count # Prefer using `contains` over `filter { }.count > 0`
- empty_count # Enforce using `isEmpty` over `count == 0`
- explicit_init # Require explicit initializers
- multiline_arguments_brackets # Enforce consistent use of brackets for multi-line arguments
- implicit_return # Opt-in to implicit return in single-expression functions
# Customize rule parameters
line_length:
warning: 120 # Warn if lines exceed 120 characters
error: 150 # Error if lines exceed 150 characters
ignores_comments: true # Ignore comments for line length
ignores_urls: true # Ignore URLs for line length
type_body_length:
warning: 250 # Warn if a type body exceeds 250 lines
error: 350 # Error if a type body exceeds 350 lines
ignores_protocols: true # Ignore protocols for type body length
function_body_length:
warning: 40 # Warn if a function body exceeds 40 lines
error: 60 # Error if a function body exceeds 60 lines
indentation_width:
width: 4 # Use 4 spaces for indentation
ignores_comments: false
ignores_empty_lines: false
trailing_whitespace:
ignores_empty_lines: true # Allow empty lines with whitespace
cyclomatic_complexity:
warning: 10 # Warn if a function has a complexity of 10
error: 15 # Error if a function has a complexity of 15
todo:
severity: warning # Set severity level for todo comments
identifiers:
- TODO
- FIXME
function_parameter_count:
warning: 5 # Warn if a function has more than 5 parameters
error: 8 # Error if a function has more than 8 parameters
# Define custom rules (if any)
custom_rules:
no_force_unwrapping:
included: ".*\\.swift" # Regex to match Swift files
name: "No Force Unwrapping"
regex: "(!)"
message: "Avoid using force unwrapping (!). Use conditional binding or optional chaining instead."
severity: error
nslocalizedstring_key:
included: ".*\\.swift"
name: "NSLocalizedString Key"
regex: "NSLocalizedString\\(\".*\""
message: "Use NSLocalizedString with proper keys for localization."
severity: warning
# Reporters to use
reporter:
- console
- emoji
- json
# Additional configurations
cache_directory: ~/Library/Caches/com.github.swiftlint