Skip to content

Commit 6698978

Browse files
author
Anton Schukin
committed
Fixed swiftlint 0.23.0 warnings
1 parent 1352e7d commit 6698978

15 files changed

+42
-28
lines changed

.swiftlint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ disabled_rules:
1111
- line_length
1212
- todo
1313
- type_body_length
14-
- variable_name
14+
- identifier_name
1515
- type_name
1616
- function_parameter_count

Chatto/Source/ChatController/BaseChatViewController+Changes.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ extension BaseChatViewController: ChatDataSourceDelegateProtocol {
197197
for move in changes.movedIndexPaths {
198198
self.collectionView.moveItem(at: move.indexPathOld, to: move.indexPathNew)
199199
}
200-
}) { [weak self] (_) -> Void in
200+
}, completion: { [weak self] (_) -> Void in
201201
defer { myCompletion() }
202202
guard let sSelf = self else { return }
203203
sSelf.unfinishedBatchUpdatesCount -= 1
204204
if sSelf.unfinishedBatchUpdatesCount == 0, let onAllBatchUpdatesFinished = self?.onAllBatchUpdatesFinished {
205205
DispatchQueue.main.async(execute: onAllBatchUpdatesFinished)
206206
}
207-
}
207+
})
208208
})
209209
} else {
210210
self.visibleCells = [:]
@@ -247,7 +247,7 @@ extension BaseChatViewController: ChatDataSourceDelegateProtocol {
247247
return self.createModelUpdates(
248248
newItems: newItems,
249249
oldItems: oldItems,
250-
collectionViewWidth:collectionViewWidth)
250+
collectionViewWidth: collectionViewWidth)
251251
}
252252

253253
if performInBackground {

Chatto/Source/ChatController/Collaborators/KeyboardTracker.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ private class KeyboardTrackingView: UIView {
219219
super.willMove(toSuperview: newSuperview)
220220
}
221221

222-
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
222+
override func observeValue(forKeyPath keyPath: String?,
223+
of object: Any?,
224+
change: [NSKeyValueChangeKey: Any]?,
225+
context: UnsafeMutableRawPointer?) {
223226
guard let object = object as? UIView, let superview = self.superview else { return }
224227
if object === superview {
225228
guard let sChange = change else { return }

Chatto/Tests/ChatController/CollectionChangesTests.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CollectionChangesTests: XCTestCase {
7070
newCollection: [Item(uid: "a"), Item(uid: "c"), Item(uid: "b")]
7171
)
7272
XCTAssertEqual(changes.deletedIndexPaths, [])
73-
XCTAssertEqual(Set(changes.movedIndexPaths), Set([Move(1, to: 2), Move(2, to:1)]))
73+
XCTAssertEqual(Set(changes.movedIndexPaths), Set([Move(1, to: 2), Move(2, to: 1)]))
7474
XCTAssertEqual(changes.insertedIndexPaths, [])
7575
}
7676

@@ -109,7 +109,9 @@ class CollectionChangesTests: XCTestCase {
109109
CollectionChangeMove(indexPathOld: indexPath4, indexPathNew: indexPath3)
110110
]
111111

112-
let changes = CollectionChanges(insertedIndexPaths: insertions, deletedIndexPaths: deletions, movedIndexPaths:movements)
112+
let changes = CollectionChanges(insertedIndexPaths: insertions,
113+
deletedIndexPaths: deletions,
114+
movedIndexPaths: movements)
113115
let result = updated(collection: collection, withChanges: changes)
114116

115117
let expected = [

ChattoAdditions/Source/Chat Items/BaseMessage/BaseMessagePresenter.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ open class BaseMessagePresenter<BubbleViewT, ViewModelBuilderT, InteractionHandl
4646
ViewModelBuilderT.ViewModelT: MessageViewModelProtocol,
4747
InteractionHandlerT: BaseMessageInteractionHandlerProtocol,
4848
InteractionHandlerT.ViewModelT == ViewModelBuilderT.ViewModelT,
49-
BubbleViewT: UIView, BubbleViewT:MaximumLayoutWidthSpecificable, BubbleViewT: BackgroundSizingQueryable {
49+
BubbleViewT: UIView,
50+
BubbleViewT: MaximumLayoutWidthSpecificable,
51+
BubbleViewT: BackgroundSizingQueryable {
52+
5053
public typealias CellT = BaseMessageCollectionViewCell<BubbleViewT>
5154
public typealias ModelT = ViewModelBuilderT.ModelT
5255
public typealias ViewModelT = ViewModelBuilderT.ViewModelT

ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCell.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ public struct BaseMessageCollectionViewCellLayoutConstants {
6565
- Have a BubbleViewType that responds properly to sizeThatFits:
6666
*/
6767

68-
open class BaseMessageCollectionViewCell<BubbleViewType>: UICollectionViewCell, BackgroundSizingQueryable, AccessoryViewRevealable, UIGestureRecognizerDelegate where BubbleViewType:UIView, BubbleViewType:MaximumLayoutWidthSpecificable, BubbleViewType: BackgroundSizingQueryable {
68+
open class BaseMessageCollectionViewCell<BubbleViewType>: UICollectionViewCell, BackgroundSizingQueryable, AccessoryViewRevealable, UIGestureRecognizerDelegate where
69+
BubbleViewType: UIView,
70+
BubbleViewType: MaximumLayoutWidthSpecificable,
71+
BubbleViewType: BackgroundSizingQueryable {
6972

7073
public var animationDuration: CFTimeInterval = 0.33
7174
open var viewContext: ViewContext = .normal

ChattoAdditions/Source/Chat Items/BaseMessage/Views/BaseMessageCollectionViewCellDefaultStyle.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ open class BaseMessageCollectionViewCellDefaultStyle: BaseMessageCollectionViewC
121121
private lazy var dateFont: UIFont = self.dateTextStyle.font()
122122
private lazy var dateFontColor: UIColor = self.dateTextStyle.color()
123123

124-
private lazy var dateStringAttributes: [String : AnyObject] = {
124+
private lazy var dateStringAttributes: [String: AnyObject] = {
125125
return [
126126
NSFontAttributeName: self.dateFont,
127127
NSForegroundColorAttributeName: self.dateFontColor

ChattoAdditions/Source/Chat Items/PhotoMessages/Views/PhotoBubbleView.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,10 @@ private class PhotoBubbleLayoutModel {
228228
}
229229

230230
init(photoMessageViewModel model: PhotoMessageViewModelProtocol, style: PhotoBubbleViewStyleProtocol, containerWidth width: CGFloat) {
231-
self.init(photoSize: style.bubbleSize(viewModel: model), tailWidth:style.tailWidth(viewModel: model), isIncoming: model.isIncoming, preferredMaxLayoutWidth: width)
231+
self.init(photoSize: style.bubbleSize(viewModel: model),
232+
tailWidth: style.tailWidth(viewModel: model),
233+
isIncoming: model.isIncoming,
234+
preferredMaxLayoutWidth: width)
232235
}
233236
}
234237

ChattoAdditions/Source/Input/ChatInputBarPresenter.swift

+3-5
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ public class BasicChatInputBarPresenter: NSObject, ChatInputBarPresenter {
8282

8383
fileprivate func firstKeyboardInputItem() -> ChatInputItemProtocol? {
8484
var firstKeyboardInputItem: ChatInputItemProtocol? = nil
85-
for inputItem in self.chatInputItems {
86-
if inputItem.presentationMode == .keyboard {
87-
firstKeyboardInputItem = inputItem
88-
break
89-
}
85+
for inputItem in self.chatInputItems where inputItem.presentationMode == .keyboard {
86+
firstKeyboardInputItem = inputItem
87+
break
9088
}
9189
return firstKeyboardInputItem
9290
}

ChattoAdditions/Source/Input/Photos/PhotosInputCameraPicker.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class PhotosInputCameraPicker: NSObject {
5050
let controller = UIImagePickerController()
5151
controller.delegate = self
5252
controller.sourceType = .camera
53-
presentingController.present(controller, animated: true, completion:nil)
53+
presentingController.present(controller, animated: true, completion: nil)
5454
}
5555

5656
fileprivate func finishPickingImage(_ image: UIImage?, fromPicker picker: UIImagePickerController) {
@@ -61,7 +61,7 @@ class PhotosInputCameraPicker: NSObject {
6161
}
6262

6363
extension PhotosInputCameraPicker: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
64-
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
64+
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String: AnyObject]?) {
6565
self.finishPickingImage(image, fromPicker: picker)
6666
}
6767

ChattoAdditions/Source/Input/Photos/PhotosInputCellProvider.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ class PhotosInputCellProvider: PhotosInputCellProviderProtocol {
8080
}
8181
imageProvidedSynchronously = false
8282

83-
self.previewRequests.setObject(NSNumber(value: requestID), forKey:cell)
83+
self.previewRequests.setObject(NSNumber(value: requestID), forKey: cell)
8484
}
8585
}

ChattoAdditions/Source/Input/ReusableXibView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import UIKit
2828

2929
func loadViewFromNib() -> UIView {
3030
let bundle = Bundle(for: type(of: self))
31-
let nib = UINib(nibName:type(of: self).nibName(), bundle: bundle)
31+
let nib = UINib(nibName: type(of: self).nibName(), bundle: bundle)
3232
let view = nib.instantiate(withOwner: nil, options: nil).first as! UIView
3333
return view
3434
}

ChattoAdditions/Source/Input/Text/TextChatInputItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ open class TextChatInputItem {
5454
}
5555

5656
// MARK: - ChatInputItemProtocol
57-
extension TextChatInputItem : ChatInputItemProtocol {
57+
extension TextChatInputItem: ChatInputItemProtocol {
5858
public var presentationMode: ChatInputItemPresentationMode {
5959
return .keyboard
6060
}

ChattoApp/ChattoApp/Source/FakeMessageFactory.swift

+8-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func createMessageModel(_ uid: String, isIncoming: Bool, type: String) -> Messag
4848

4949
func createPhotoMessageModel(_ uid: String, image: UIImage, size: CGSize, isIncoming: Bool) -> DemoPhotoMessageModel {
5050
let messageModel = createMessageModel(uid, isIncoming: isIncoming, type: PhotoMessageModel<MessageModel>.chatItemType)
51-
let photoMessageModel = DemoPhotoMessageModel(messageModel: messageModel, imageSize:size, image: image)
51+
let photoMessageModel = DemoPhotoMessageModel(messageModel: messageModel, imageSize: size, image: image)
5252
return photoMessageModel
5353
}
5454

@@ -85,8 +85,6 @@ class FakeMessageFactory {
8585
imageSize = CGSize(width: 400, height: 300)
8686
case 1:
8787
imageSize = CGSize(width: 300, height: 400)
88-
case 2:
89-
fallthrough
9088
default:
9189
imageSize = CGSize(width: 300, height: 300)
9290
}
@@ -97,8 +95,6 @@ class FakeMessageFactory {
9795
imageName = "pic-test-1"
9896
case 1:
9997
imageName = "pic-test-2"
100-
case 2:
101-
fallthrough
10298
default:
10399
imageName = "pic-test-3"
104100
}
@@ -146,7 +142,13 @@ class TutorialMessageFactory {
146142
result.append(createTextMessageModel("tutorial-\(index)", text: content, isIncoming: isIncoming))
147143
} else {
148144
let image = UIImage(named: content)!
149-
result.append(createPhotoMessageModel("tutorial-\(index)", image:image, size: image.size, isIncoming: isIncoming))
145+
let photoMessage = createPhotoMessageModel(
146+
"tutorial-\(index)",
147+
image: image,
148+
size: image.size,
149+
isIncoming: isIncoming
150+
)
151+
result.append(photoMessage)
150152
}
151153
}
152154
return result

ChattoApp/ChattoApp/Source/Sending status/SendingStatusPresenter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class SendingStatusPresenter: ChatItemPresenterProtocol {
8585
}
8686

8787
let attrs = [
88-
NSFontAttributeName : UIFont.systemFont(ofSize: 10.0),
88+
NSFontAttributeName: UIFont.systemFont(ofSize: 10.0),
8989
NSForegroundColorAttributeName: self.statusModel.status == .failed ? UIColor.red : UIColor.black
9090
]
9191
statusCell.text = NSAttributedString(

0 commit comments

Comments
 (0)