Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 3f6fb5e

Browse files
authored
Improve swift style + swiftlint (#1092)
Task/Issue URL: https://app.asana.com/0/0/1201986385932308/f Description: Implement style guide changes Update swift lint Fork style from RW repo with some added changes
1 parent 207ea9d commit 3f6fb5e

74 files changed

Lines changed: 1241 additions & 116 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.

‎.swiftlint.yml‎

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,56 @@
11

22
disabled_rules:
3-
- trailing_whitespace
3+
- discarded_notification_center_observer
4+
- notification_center_detachment
5+
- orphaned_doc_comment
6+
- todo
7+
- unused_capture_list
8+
9+
opt_in_rules:
10+
- closure_end_indentation
11+
- closure_spacing
12+
- colon
13+
- overridden_super_call
14+
- unused_import
15+
- fatal_error_message
16+
17+
force_cast: warning
18+
force_try: warning
19+
legacy_hashing: error
420

5-
# Rule Config
6-
line_length:
7-
warning: 150
8-
ignores_comments: true
921
identifier_name:
1022
min_length: 1
1123
max_length:
1224
warning: 40
1325
error: 60
26+
excluded:
27+
- i
28+
- id
29+
- x
30+
- y
31+
- z
32+
33+
line_length:
34+
warning: 150
35+
ignores_urls: true
36+
ignores_function_declarations: true
37+
ignores_comments: true
38+
39+
vertical_whitespace:
40+
max_empty_lines: 2
41+
42+
trailing_whitespace:
43+
ignores_empty_lines: true
44+
ignores_comments: true
45+
46+
private_over_fileprivate:
47+
validate_extensions: true
48+
1449
type_name:
15-
min_length: 3
16-
max_length:
17-
warning: 80
18-
error: 100
50+
min_length: 3
51+
max_length:
52+
warning: 80
53+
error: 100
1954

2055
# General Config
2156
excluded:

‎AtbUITests/AtbIntegrationTests.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class AtbIntegrationTests: XCTestCase {
137137

138138
}
139139

140-
fileprivate extension HttpRequest {
140+
private extension HttpRequest {
141141

142142
func queryParam(_ named: String) -> String? {
143143
return queryParams.first(where: { $0.0 == named })?.1

‎Core/APIRequest.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class APIRequest {
8888

8989
if let error = error {
9090
completion(nil, error)
91-
} else if let error = httpResponse?.validateStatusCode(statusCode: 200..<300) {
91+
} else if let error = httpResponse?.validateStatusCode(statusCode: 200..<300) {
9292
completion(nil, error)
9393
} else {
9494
var etag = httpResponse?.headerValue(for: APIHeaders.Name.etag)

‎Core/BookmarkObjects.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private struct Constants {
3434
public protocol Bookmark: BookmarkItem {
3535
var url: URL? { get set }
3636

37-
var displayTitle: String? { get }
37+
var displayTitle: String? { get }
3838
}
3939

4040
public extension Bookmark {

‎Core/BookmarksCoreDataStorage.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class BookmarksCoreDataStorage {
132132
context.perform {
133133
handler(context)
134134
self.storeLoadedCondition.resolve()
135-
}
135+
}
136136
}
137137
}
138138
}
@@ -422,7 +422,7 @@ extension BookmarksCoreDataStorage {
422422
loadStore()
423423
}
424424

425-
public func favoritesUncachedForWidget(completion: @escaping ([BookmarkManagedObject]) -> Void) {
425+
public func favoritesUncachedForWidget(completion: @escaping ([BookmarkManagedObject]) -> Void) {
426426
Task {
427427
guard await hasTopLevelFolder() else {
428428
completion([])

‎Core/Database.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ private class DDGPersistentContainer: NSPersistentContainer {
122122
override public class func defaultDirectoryURL() -> URL {
123123

124124
return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Database.Constants.databaseGroupID)!
125-
}
125+
}
126126
}

‎Core/PartiallyRoundedRectangleView.swift‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public class PartiallyRoundedRectangleView: UIView {
4747
override public func layoutSubviews() {
4848
super.layoutSubviews()
4949
var corners = UIRectCorner()
50-
if topLeftCorner { corners.insert(.topLeft) }
51-
if topRightCorner { corners.insert(.topRight) }
52-
if bottomLeftCorner { corners.insert(.bottomLeft) }
50+
if topLeftCorner { corners.insert(.topLeft) }
51+
if topRightCorner { corners.insert(.topRight) }
52+
if bottomLeftCorner { corners.insert(.bottomLeft) }
5353
if bottomRightCorner { corners.insert(.bottomRight) }
5454
round(corners: corners, radius: cornerRadius)
5555
}

‎Core/PrivacyPractices.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class PrivacyPractices {
7272

7373
func findPractice(forHost host: String) -> Practice {
7474
guard let domain = tld.domain(host) else { return Constants.unknown }
75-
guard let term = termsOfServiceStore.terms[domain] else { return Constants.unknown}
75+
guard let term = termsOfServiceStore.terms[domain] else { return Constants.unknown }
7676
let entityScore = entityScores[entityMapping.findEntity(forHost: domain)?.displayName ?? ""]
7777
return Practice(score: entityScore ?? term.derivedScore,
7878
summary: term.summary,

‎Core/WebCacheManager.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public class WebCacheManager {
113113
cookieStore.getAllCookies { cookies in
114114
let group = DispatchGroup()
115115
cookies.forEach { cookie in
116-
if domains.contains(where: { self.isCookie(cookie, matchingDomain: $0)}) {
116+
if domains.contains(where: { self.isCookie(cookie, matchingDomain: $0) }) {
117117
group.enter()
118118
cookieStore.delete(cookie) {
119119
group.leave()

‎DuckDuckGo/ActionSheetDaxDialogViewController.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ActionSheetDaxDialogViewController: UIViewController {
7474
override func viewWillAppear(_ animated: Bool) {
7575
super.viewWillAppear(animated)
7676

77-
containerHeight.constant = daxDialogViewController?.calculateHeight() ?? 0
77+
containerHeight.constant = daxDialogViewController?.calculateHeight() ?? 0
7878
}
7979

8080
override func viewDidAppear(_ animated: Bool) {

0 commit comments

Comments
 (0)