Skip to content

Commit d7c8696

Browse files
committed
refactor: format code
1 parent 3313850 commit d7c8696

84 files changed

Lines changed: 1031 additions & 812 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.swiftformat

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md
2+
3+
# format options
4+
5+
--symlinks ignore
6+
--swiftversion 6.2
7+
8+
# format options
9+
10+
--closingparen same-line
11+
--commas inline
12+
--comments indent
13+
--decimalgrouping 3,4
14+
--exponentcase lowercase
15+
--exponentgrouping disabled
16+
--fractiongrouping disabled
17+
--ifdef no-indent
18+
--importgrouping testable-top
19+
--nospaceoperators ..<, ...
20+
--selfrequired validate
21+
--stripunusedargs closure-only
22+
--wraparguments after-first
23+
--wrapcollections after-first
24+
--wrapparameters after-first
25+
--disable wrapArguments
26+
--indent 4
27+
--maxwidth 115
28+
--wrapcollections before-first
29+
--ranges no-space
30+
31+
# rules
32+
33+
--disable wrapMultilineStatementBraces
34+
35+
36+
--enable isEmpty,\
37+
blankLineAfterImports,\
38+
sortSwitchCases,\
39+
redundantAsync,\
40+

.swiftlint.yml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# You can find the documentation here :
2+
# https://realm.github.io/SwiftLint/rule-directory.html
3+
4+
##############
5+
#Disabled rules#
6+
##############
7+
8+
disabled_rules:
9+
- nesting
10+
11+
##############
12+
#Opted in rules#
13+
##############
14+
15+
opt_in_rules:
16+
- array_init
17+
- closure_spacing
18+
- collection_alignment
19+
- contains_over_filter_count
20+
- contains_over_filter_is_empty
21+
- contains_over_first_not_nil
22+
- contains_over_range_nil_comparison
23+
- convenience_type
24+
- discouraged_object_literal
25+
- discouraged_optional_boolean
26+
- empty_collection_literal
27+
- empty_count
28+
- empty_xctest_method
29+
- enum_case_associated_values_count
30+
- expiring_todo
31+
- explicit_init
32+
- extension_access_modifier
33+
- fallthrough
34+
- fatal_error_message
35+
- file_name_no_space
36+
- first_where
37+
- flatmap_over_map_reduce
38+
- force_unwrapping
39+
- ibinspectable_in_extension
40+
- identical_operands
41+
- implicit_return
42+
- joined_default_parameter
43+
- last_where
44+
- legacy_multiple
45+
- legacy_random
46+
- let_var_whitespace
47+
- literal_expression_end_indentation
48+
- multiline_arguments
49+
- multiline_parameters
50+
- nimble_operator
51+
- nslocalizedstring_key
52+
- nslocalizedstring_require_bundle
53+
- number_separator
54+
- operator_usage_whitespace
55+
- optional_enum_case_matching
56+
- overridden_super_call
57+
- override_in_extension
58+
- pattern_matching_keywords
59+
- prefer_self_type_over_type_of_self
60+
- prefer_zero_over_explicit_init
61+
- prefixed_toplevel_constant
62+
- private_action
63+
- private_outlet
64+
- prohibited_super_call
65+
- quick_discouraged_call
66+
- quick_discouraged_focused_test
67+
- quick_discouraged_pending_test
68+
- raw_value_for_camel_cased_codable_enum
69+
- reduce_into
70+
- redundant_nil_coalescing
71+
- redundant_type_annotation
72+
- required_enum_case
73+
- single_test_class
74+
- sorted_first_last
75+
- sorted_imports
76+
- static_operator
77+
- toggle_bool
78+
- trailing_closure
79+
- unavailable_function
80+
- unneeded_parentheses_in_closure_argument
81+
- untyped_error_in_catch
82+
- vertical_parameter_alignment_on_call
83+
- vertical_whitespace_closing_braces
84+
- vertical_whitespace_opening_braces
85+
- xct_specific_matcher
86+
- yoda_condition
87+
- unhandled_throwing_task
88+
89+
##############
90+
#Specific analyzer rules#
91+
##############
92+
93+
analyzer_rules: # Rules run by `swiftlint analyze`
94+
- explicit_self
95+
- unused_declaration
96+
- unused_import
97+
98+
################
99+
#Customed rules#
100+
################
101+
102+
# configurable rules can be customized from this configuration file
103+
# binary rules can set their severity level
104+
#force_cast: warning # implicitly
105+
106+
#force_try:
107+
# severity: warning # explicitly
108+
#
109+
# rules that have both warning and error levels, can set just the warning level
110+
# implicitly
111+
line_length:
112+
warning: 120
113+
error: 200
114+
ignores_urls: true
115+
ignores_comments: true
116+
117+
# they can set both implicitly with an array
118+
type_body_length:
119+
warning: 300
120+
error: 400
121+
122+
trailing_closure:
123+
only_single_muted_parameter: true
124+
125+
trailing_whitespace:
126+
ignores_empty_lines: true
127+
128+
# or they can set both explicitly
129+
file_length:
130+
warning: 700
131+
error: 1200
132+
133+
function_body_length: # Functions bodies should not span too many lines.
134+
warning: 100
135+
error: 200
136+
137+
# naming rules can set warnings/errors for min_length and max_length
138+
# additionally they can set excluded names
139+
type_name:
140+
min_length: 3 # only warning
141+
max_length: # warning and error
142+
warning: 45
143+
error: 50
144+
excluded: iPhone # excluded via string
145+
allowed_symbols: ["_"] # these are allowed in type names
146+
147+
identifier_name:
148+
min_length: # only min_length
149+
warning: 2
150+
excluded: # excluded via string array
151+
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown)
152+
153+
custom_rules:
154+
drop_first_one:
155+
name: "Drop first one"
156+
message: "Implicitly drop first one element"
157+
regex: "(\\.dropFirst\\(1\\))"
158+
159+
discouraged_optional_self:
160+
name: "Discouraged optional self"
161+
message: "Unwrap self via guard let and use implicit self instead of optional self"
162+
regex: "(self\\?\\.)"
163+
164+
discouraged_previewprovider:
165+
name: "Discouraged PreviewProvider"
166+
message: "Use #Preview macro insteaf of PreviewProvider"
167+
regex: "(PreviewProvider)"
168+
169+
discouraged_anyview:
170+
name: "Discouraged AnyView"
171+
message: "Avoid using AnyView for better performance"
172+
regex: "(AnyView)"
173+
174+
discouraged_body_font:
175+
name: "Discouraged body font"
176+
message: "Prefer implicit body font"
177+
regex: "(\\.font\\(\\.body\\))"
178+
179+
discouraged_regular_font_weight:
180+
name: "Discouraged regular font weight"
181+
message: "Prefer implicit regular font weight"
182+
regex: "(\\.fontWeight\\(\\.regular\\))"
183+
184+
discouraged_verbose_contentshape_rectangle:
185+
name: "Discouraged verbose .contentShape(Rectangle())"
186+
message: "Prefer static member lookup version .contentShape(.rectangle)"
187+
regex: "(\\.contentShape\\(Rectangle\\(\\))"
188+
189+
deprecated_foregroundcolor_modifier:
190+
name: "Deprecated foregroundColor modifier"
191+
message: "Prefer foregroundStyle over deprecated foregroundColor"
192+
regex: "(foregroundColor\\()"
193+
194+
deprecated_navigationbarleading:
195+
name: "Deprecated navigationBarLeading"
196+
message: "Prefer topBarLeading over deprecated navigationBarLeading"
197+
regex: "\\.navigationBarLeading"
198+
199+
deprecated_navigationbartrailing:
200+
name: "Deprecated navigationBarTrailing"
201+
message: "Prefer topBarTrailing over deprecated navigationBarTrailing"
202+
regex: "\\.navigationBarTrailing"
203+
204+
nil_if_empty:
205+
name: "Nil if empty"
206+
message: "Use Collection's computed property nilIfEmpty"
207+
regex: "\\.isEmpty \\? nil"

SimpleLogin/Keyboard Extension/CreatedAliasView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct CreatedAliasView: View {
2525
}, label: {
2626
Label("Back", systemImage: "arrowshape.turn.up.backward.fill")
2727
})
28-
.foregroundColor(.slPurple)
28+
.foregroundColor(.slPurple)
2929
}
3030
.padding(.horizontal, 44)
3131
}

SimpleLogin/Keyboard Extension/KeyboardContentView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct KeyboardContentView: View {
1414

1515
init(session: Session, onTap: @escaping (Alias) -> Void) {
1616
_viewModel = StateObject(wrappedValue: .init(session: session))
17-
self.onSelectAlias = onTap
17+
onSelectAlias = onTap
1818
}
1919

2020
var body: some View {
@@ -31,7 +31,7 @@ struct KeyboardContentView: View {
3131
}, label: {
3232
Label("Retry", systemImage: "gobackward")
3333
})
34-
.foregroundColor(.slPurple)
34+
.foregroundColor(.slPurple)
3535
}
3636
.padding()
3737
} else {
@@ -69,7 +69,7 @@ final class KeyboardContentViewModel: ObservableObject {
6969
}
7070

7171
func getMoreAliasesIfNeed(currentAlias alias: Alias?) {
72-
guard let alias = alias else {
72+
guard let alias else {
7373
getMoreAliases()
7474
return
7575
}
@@ -81,7 +81,7 @@ final class KeyboardContentViewModel: ObservableObject {
8181
}
8282

8383
private func getMoreAliases() {
84-
guard !isLoading && canLoadMorePages else { return }
84+
guard !isLoading, canLoadMorePages else { return }
8585
Task { @MainActor in
8686
defer { isLoading = false }
8787
isLoading = true

SimpleLogin/Keyboard Extension/KeyboardViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class KeyboardViewController: UIInputViewController {
3434

3535
private func setSession(session: Session?) {
3636
let subView: UIView
37-
if let session = session {
37+
if let session {
3838
let contentView = KeyboardContentView(session: session) { [unowned self] alias in
3939
textDocumentProxy.insertText(alias.email)
4040
}

SimpleLogin/ShareExtension/ShareViewController.swift

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class ShareViewController: UIViewController {
2020
self.setUpUI()
2121
} catch {
2222
alert(error: error) { [unowned self] in
23-
self.dismiss()
23+
dismiss()
2424
}
2525
}
2626
}
@@ -42,17 +42,16 @@ final class ShareViewController: UIViewController {
4242

4343
private func setSession(session: Session?) {
4444
let subView: UIView
45-
if let session = session {
46-
let createAliasView = CreateAliasView(
47-
session: session,
48-
mode: createAliasViewMode,
49-
onCreateAlias: { [unowned self] alias in
50-
self.handleAliasCreation(alias: alias)
51-
},
52-
onCancel: { [unowned self] in
53-
self.dismiss()
54-
},
55-
onOpenMyAccount: nil)
45+
if let session {
46+
let createAliasView = CreateAliasView(session: session,
47+
mode: createAliasViewMode,
48+
onCreateAlias: { [unowned self] alias in
49+
handleAliasCreation(alias: alias)
50+
},
51+
onCancel: { [unowned self] in
52+
dismiss()
53+
},
54+
onOpenMyAccount: nil)
5655
let hostingController = UIHostingController(rootView: createAliasView)
5756
subView = hostingController.view
5857
addChild(hostingController)
@@ -114,19 +113,19 @@ final class ShareViewController: UIViewController {
114113
preferredStyle: .alert)
115114
let copyAndCloseAction = UIAlertAction(title: "Copy & close", style: .default) { [unowned self] _ in
116115
UIPasteboard.general.string = alias.email
117-
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
116+
extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
118117
}
119118
alert.addAction(copyAndCloseAction)
120119

121120
let closeAction = UIAlertAction(title: "Close", style: .cancel) { [unowned self] _ in
122-
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
121+
extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
123122
}
124123
alert.addAction(closeAction)
125124
alert.view.tintColor = .slPurple
126125
present(alert, animated: true, completion: nil)
127126
}
128127

129128
private func dismiss() {
130-
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
129+
extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
131130
}
132131
}

SimpleLogin/SimpleLogin/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import SwiftyStoreKit
99
import UIKit
1010

1111
final class AppDelegate: NSObject, UIApplicationDelegate {
12-
func application(_ application: UIApplication,
12+
func application(_: UIApplication,
1313
// swiftlint:disable:next line_length
14-
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
14+
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
1515
UIView.appearance(whenContainedInInstancesOf:
16-
[UIAlertController.self]).tintColor = .slPurple
16+
[UIAlertController.self]).tintColor = .slPurple
1717
SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
1818
for purchase in purchases {
1919
switch purchase.transaction.transactionState {

0 commit comments

Comments
 (0)