Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit c23945a

Browse files
authored
Enable SwiftLint and fix issues (#2292)
* update swiftlint * build with lint enabled * fix almost all warnings * remove wholemodule
1 parent 96e9554 commit c23945a

File tree

181 files changed

+431
-832
lines changed

Some content is hidden

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

181 files changed

+431
-832
lines changed

.swiftlint.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
disabled_rules:
22
- function_parameter_count
3-
- line_length
4-
- identifier_name
5-
- type_name
63
- function_body_length
74
- type_body_length
85
- force_try
96
- force_cast
10-
- trailing_whitespace
7+
- cyclomatic_complexity
8+
- identifier_name
9+
- type_name
10+
- line_length
11+
- file_length
12+
- large_tuple
13+
- nesting
1114

1215
included:
1316
- Classes
1417
- FreetimeTests
18+
- Local\ Pods
1519
excluded:
1620
- Pods
17-
- Local Pods
1821
- Playgrounds
19-
- Sample
22+
- Local\ Pods/SwipeCellKit
2023

2124
reporter: "xcode"

Classes/Bookmark/BookmarkCell.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class BookmarkCell: SwipeSelectableCell {
2525

2626
override init(frame: CGRect) {
2727
super.init(frame: frame)
28-
28+
2929
backgroundColor = .white
3030

3131
contentView.clipsToBounds = true
@@ -84,14 +84,14 @@ final class BookmarkCell: SwipeSelectableCell {
8484
string: "\(viewModel.bookmark.owner)/\(viewModel.bookmark.name)",
8585
attributes: [
8686
.font: Styles.Text.secondaryBold.preferredFont,
87-
.foregroundColor: Styles.Colors.Gray.light.color,
87+
.foregroundColor: Styles.Colors.Gray.light.color
8888
]
8989
)
9090
detailString.append(NSAttributedString(
9191
string: " #\(viewModel.bookmark.number)",
9292
attributes: [
9393
.font: Styles.Text.secondary.preferredFont,
94-
.foregroundColor: Styles.Colors.Gray.light.color,
94+
.foregroundColor: Styles.Colors.Gray.light.color
9595
]
9696
))
9797
detailLabel.attributedText = detailString

Classes/Bookmark/BookmarkNavigationController.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ final class BookmarkNavigationController {
2323
}
2424

2525
// MARK: Public API
26-
26+
2727
var navigationItem: UIBarButtonItem {
2828
let item = UIBarButtonItem()
2929
configureNavigationItem(item)
3030
return item
3131
}
32-
32+
3333
func configureNavigationItem(_ item: UIBarButtonItem) {
34-
34+
3535
let accessibilityLabel: String
3636
let imageName: String
3737
let selector: Selector
38-
38+
3939
if store.contains(model) {
4040
imageName = "nav-bookmark-selected"
4141
accessibilityLabel = Constants.Strings.removeBookmark
@@ -45,7 +45,7 @@ final class BookmarkNavigationController {
4545
accessibilityLabel = Constants.Strings.bookmark
4646
selector = #selector(BookmarkNavigationController.add(sender:))
4747
}
48-
48+
4949
item.accessibilityLabel = accessibilityLabel
5050
item.image = UIImage(named: imageName)?.withRenderingMode(.alwaysTemplate)
5151
item.target = self
@@ -54,7 +54,7 @@ final class BookmarkNavigationController {
5454
item.width = 0
5555
item.imageInsets = BookmarkNavigationController.iconImageInset
5656
}
57-
57+
5858
//for timeframe between viewDidLoad() and bookmark info is loaded
5959
static var disabledNavigationItem: UIBarButtonItem {
6060
let item = UIBarButtonItem()
@@ -63,20 +63,20 @@ final class BookmarkNavigationController {
6363
item.imageInsets = BookmarkNavigationController.iconImageInset
6464
return item
6565
}
66-
66+
6767
// MARK: Private API
68-
68+
6969
@objc func add(sender: UIBarButtonItem) {
7070
Haptic.triggerSelection()
7171
sender.action = #selector(BookmarkNavigationController.remove(sender:))
7272
sender.image = UIImage(named: "nav-bookmark-selected")?.withRenderingMode(.alwaysTemplate)
7373
store.add(model)
7474
}
75-
75+
7676
@objc func remove(sender: UIBarButtonItem) {
7777
sender.action = #selector(BookmarkNavigationController.add(sender:))
7878
sender.image = UIImage(named: "nav-bookmark")?.withRenderingMode(.alwaysTemplate)
7979
store.remove(model)
8080
}
81-
81+
8282
}

Classes/Bookmark/BookmarkViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ TabNavRootViewControllerType {
9898
collectionView.collectionViewLayout.invalidateForOrientationChange()
9999
}
100100
}
101-
101+
102102
override func viewWillDisappear(_ animated: Bool) {
103103
searchBar.resignFirstResponder()
104104
}
105105

106-
107106
private func update(animated: Bool) {
108107
adapter.performUpdates(animated: animated)
109108
}

Classes/Image Upload/ImageUploadTableViewController.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,13 @@ class ImageUploadTableViewController: UITableViewController {
5050

5151
return viewController
5252
}
53-
53+
5454
override func viewDidLoad() {
5555
super.viewDidLoad()
5656

5757
// Set the preview image
5858
previewImageView.image = image
5959

60-
6160
// Set the right button item to spinning until we have compression info
6261
setRightBarItemSpinning()
6362

@@ -76,7 +75,7 @@ class ImageUploadTableViewController: UITableViewController {
7675
]
7776
)
7877
titleTextField.delegate = self
79-
78+
8079
// Compress and encode the image in the background to speed up the upload process
8180
image.compressAndEncode { [weak self] result in
8281
switch result {
@@ -159,18 +158,18 @@ class ImageUploadTableViewController: UITableViewController {
159158
client.canUploadImage { [weak self] error in
160159
// Ensure that we do have enough tokens, otherwise remove the upload button
161160
if let error = error as? ImgurClient.ImgurError {
162-
161+
163162
switch error {
164163
case .endpointError(let response):
165164
Squawk.showError(message: response)
166-
165+
167166
case .rateLimitExceeded:
168167
Squawk.showError(message: NSLocalizedString("Rate Limit reached, cannot upload!", comment: ""))
169-
168+
170169
default:
171170
Squawk.showGenericError()
172171
}
173-
172+
174173
self?.navigationItem.rightBarButtonItem = nil
175174
return
176175
}
@@ -201,7 +200,7 @@ class ImageUploadTableViewController: UITableViewController {
201200
}
202201
}
203202
}
204-
203+
205204
@IBAction func didPressPreviewImage() {
206205
let previewViewController = NYTPhotosViewController(photos: [IssueCommentPhoto(image: image, data: nil)])
207206
present(previewViewController, animated: trueUnlessReduceMotionEnabled)

Classes/Image Upload/ImgurClient.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ final class ImgurClient {
1414
enum ImgurError: Error {
1515
// missingLink: - Received a valid response, but no link was available in the payload
1616
case missingLink
17-
17+
1818
// endpointError: - We got an error back from Imgur, where the parameter is their response
1919
case endpointError(String)
20-
20+
2121
// malformedResponse: - We got a response back from Imgur, but it did not contain values we expected
2222
case malformedResponse
23-
23+
2424
// rateLimitExceeded: - We are too close to the Imgur rate limit, so no images are being permitted
2525
case rateLimitExceeded
2626
}
@@ -56,7 +56,7 @@ final class ImgurClient {
5656
completion(ImgurError.malformedResponse)
5757
return
5858
}
59-
59+
6060
if let error = data["error"] as? String {
6161
completion(ImgurError.endpointError(error))
6262
return
@@ -73,7 +73,7 @@ final class ImgurClient {
7373
completion(ImgurError.rateLimitExceeded)
7474
return
7575
}
76-
76+
7777
completion(nil)
7878
}
7979
}

Classes/Issues/AddCommentClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class AddCommentClient {
4747
let mutation = AddCommentMutation(subject_id: subjectId, body: bodyWithSignature)
4848
client.client.mutate(mutation, result: { data in
4949
data.addComment?.commentEdge.node
50-
}) { result in
50+
}, completion: { result in
5151
switch result {
5252
case .success(let commentNode):
5353
let fragments = commentNode.fragments
@@ -67,7 +67,7 @@ final class AddCommentClient {
6767
}
6868
Squawk.show(error: error)
6969
}
70-
}
70+
})
7171
}
7272

7373
}

Classes/Issues/Assignees/IssueAssigneeAvatarCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class IssueAssigneeAvatarCell: UICollectionViewCell {
2222
imageView.layer.borderWidth = 1.0 / UIScreen.main.scale
2323
imageView.clipsToBounds = true
2424
imageView.accessibilityIgnoresInvertColors = true
25-
25+
2626
contentView.addSubview(imageView)
2727
}
2828

Classes/Issues/Assignees/IssueAssigneeUserCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class IssueAssigneeUserCell: UICollectionViewCell, ListBindable {
2525
imageView.layer.borderWidth = 1.0 / UIScreen.main.scale
2626
imageView.clipsToBounds = true
2727
imageView.accessibilityIgnoresInvertColors = true
28-
28+
2929
contentView.addSubview(imageView)
3030
imageView.snp.makeConstraints { make in
3131
make.centerY.equalToSuperview()

Classes/Issues/Branches/IssueBranchesSectionController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ import UIKit
1010
import IGListKit
1111

1212
final class IssueTargetBranchSectionController: ListSectionController {
13-
13+
1414
var object: IssueTargetBranchModel?
15-
15+
1616
override func didUpdate(to object: Any) {
1717
guard let object = object as? IssueTargetBranchModel else { return }
1818
self.object = object
1919
}
20-
20+
2121
override func sizeForItem(at index: Int) -> CGSize {
2222
guard let width = collectionContext?.insetContainerSize.width else { fatalError("Collection context must be set") }
2323
return CGSize(width: width, height: self.object?.targetBranchText.viewSize(in: width).height ?? 0)
2424
}
25-
25+
2626
override func cellForItem(at index: Int) -> UICollectionViewCell {
2727
guard let object = self.object,
2828
let cell = collectionContext?.dequeueReusableCell(of: IssueTargetBranchCell.self, for: self, at: index) as? IssueTargetBranchCell

0 commit comments

Comments
 (0)