Tweak swiftlint settings

This commit is contained in:
Stefan Ceriu 2023-08-08 09:50:43 +03:00 committed by Stefan Ceriu
parent 10259e9345
commit dd6d1f6e63
20 changed files with 9 additions and 28 deletions

View File

@ -24,7 +24,7 @@ line_length:
error: 1000
file_length:
warning: 800
warning: 1000
error: 1000
type_name:
@ -38,9 +38,12 @@ type_body_length:
error: 1000
function_body_length:
warning: 50
warning: 100
error: 100
cyclomatic_complexity:
ignores_case_statements: true
nesting:
type_level:
warning: 5

View File

@ -241,7 +241,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
userSessionStore.reset()
}
// swiftlint:disable:next cyclomatic_complexity
private func setupStateMachine() {
stateMachine.addTransitionHandler { [weak self] context in
guard let self else { return }

View File

@ -95,7 +95,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
// MARK: - Private
// swiftlint:disable:next cyclomatic_complexity function_body_length
// swiftlint:disable:next function_body_length
private func setupStateMachine() {
stateMachine.addRouteMapping { event, fromState, _ in
switch (event, fromState) {
@ -258,7 +258,6 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
}
}
// swiftlint:disable:next cyclomatic_complexity function_body_length
private func asyncPresentRoom(_ roomID: String, animated: Bool, destinationRoomProxy: RoomProxyProtocol? = nil) async {
if let roomProxy, roomProxy.id == roomID {
navigationStackCoordinator.popToRoot()

View File

@ -135,7 +135,6 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
// MARK: - Private
// swiftlint:disable:next cyclomatic_complexity function_body_length
private func setupStateMachine() {
stateMachine.addTransitionHandler { [weak self] context in
guard let self else { return }
@ -241,7 +240,6 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
}
}
// swiftlint:disable:next cyclomatic_complexity
private func presentHomeScreen() {
let parameters = HomeScreenCoordinatorParameters(userSession: userSession,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL),

View File

@ -114,7 +114,6 @@ class UserSessionFlowCoordinatorStateMachine {
configure()
}
// swiftlint:disable:next cyclomatic_complexity
private func configure() {
stateMachine.addRoutes(event: .start, transitions: [.initial => .roomList(selectedRoomID: nil)])
stateMachine.addRoutes(event: .startWithMigration, transitions: [.initial => .migration])

View File

@ -101,7 +101,6 @@ extension UNMutableNotificationContent {
return self
}
// swiftlint:disable:next function_body_length
func addSenderIcon(using mediaProvider: MediaProviderProtocol?,
senderID: String,
senderName: String,

View File

@ -34,7 +34,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
var callback: ((HomeScreenViewModelAction) -> Void)?
// swiftlint:disable:next function_body_length cyclomatic_complexity
init(userSession: UserSessionProtocol,
attributedStringBuilder: AttributedStringBuilderProtocol,
selectedRoomPublisher: CurrentValuePublisher<String?, Never>,
@ -156,7 +155,6 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
// MARK: - Public
// swiftlint:disable:next cyclomatic_complexity
override func process(viewAction: HomeScreenViewAction) {
switch viewAction {
case .selectRoom(let roomIdentifier):

View File

@ -69,7 +69,6 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
// MARK: - Public
// swiftlint:disable:next cyclomatic_complexity
override func process(viewAction: RoomDetailsScreenViewAction) {
switch viewAction {
case .processTapPeople:

View File

@ -59,7 +59,6 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
// MARK: - Public
// swiftlint:disable:next cyclomatic_complexity
func start() {
viewModel.callback = { [weak self] action in
guard let self else { return }

View File

@ -81,7 +81,6 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
var callback: ((RoomScreenViewModelAction) -> Void)?
// swiftlint:disable:next cyclomatic_complexity function_body_length
override func process(viewAction: RoomScreenViewAction) {
switch viewAction {
case .displayRoomDetails:
@ -539,7 +538,6 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
item.isOutgoing || (canCurrentUserRedact && !roomProxy.isDirect)
}
// swiftlint:disable:next cyclomatic_complexity function_body_length
private func processTimelineItemMenuAction(_ action: TimelineItemMenuAction, itemID: TimelineItemIdentifier) {
guard let timelineItem = timelineController.timelineItems.firstUsingStableID(itemID),
let eventTimelineItem = timelineItem as? EventBasedTimelineItemProtocol else {

View File

@ -33,7 +33,7 @@ struct LongPressWithFeedback: ViewModifier {
.animation(isLongPressing ? .spring(response: 0.5).delay(0.1) : .spring(response: 0.5),
value: isLongPressing)
// The minimum duration here doesn't actually invoke the perform block when elapsed (thus
// the implementation bellow) but it does cancel other system gestures e.g. swipe to reply
// the implementation below) but it does cancel other system gestures e.g. swipe to reply
.onLongPressGesture(minimumDuration: 0.25) { } onPressingChanged: { isPressing in
isLongPressing = isPressing

View File

@ -83,7 +83,6 @@ class SessionVerificationScreenStateMachine {
configure()
}
// swiftlint:disable:next cyclomatic_complexity
private func configure() {
stateMachine.addRoutes(event: .requestVerification, transitions: [.initial => .requestingVerification])
stateMachine.addRoutes(event: .didAcceptVerificationRequest, transitions: [.requestingVerification => .verificationRequestAccepted])

View File

@ -101,7 +101,6 @@ class BugReportService: NSObject, BugReportServiceProtocol {
SentrySDK.crash()
}
// swiftlint:disable:next function_body_length cyclomatic_complexity
func submitBugReport(_ bugReport: BugReport,
progressListener: CurrentValueSubject<Double, Never>) async -> Result<SubmitBugReportResponse, BugReportServiceError> {
var params = [

View File

@ -23,7 +23,6 @@ struct RoomEventStringBuilder {
self.stateEventStringBuilder = stateEventStringBuilder
}
// swiftlint:disable:next cyclomatic_complexity
func buildAttributedString(for eventItemProxy: EventTimelineItemProxy) -> AttributedString? {
let sender = eventItemProxy.sender
let isOutgoing = eventItemProxy.isOwn

View File

@ -206,7 +206,6 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
}
}
// swiftlint:disable:next cyclomatic_complexity function_body_length
private func buildDiff(from diff: RoomListEntriesUpdate, on rooms: [RoomSummary]) -> CollectionDifference<RoomSummary>? {
var changes = [CollectionDifference<RoomSummary>.Change]()

View File

@ -89,7 +89,7 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
MXLog.verbose("Finished applying diffs, current items (\(itemProxies.count)) : \(itemProxies.map(\.debugIdentifier))")
}
// swiftlint:disable:next cyclomatic_complexity function_body_length
// swiftlint:disable:next cyclomatic_complexity
private func buildDiff(from diff: TimelineDiff, on itemProxies: [TimelineItemProxy]) -> CollectionDifference<TimelineItemProxy>? {
var changes = [CollectionDifference<TimelineItemProxy>.Change]()

View File

@ -20,7 +20,6 @@ import UIKit
struct RoomStateEventStringBuilder {
let userID: String
// swiftlint:disable:next cyclomatic_complexity
func buildString(for change: MembershipChange?, member: String, sender: TimelineItemSender, isOutgoing: Bool) -> String? {
guard let change else {
MXLog.verbose("Filtering timeline item for membership change that is nil")
@ -76,7 +75,7 @@ struct RoomStateEventStringBuilder {
}
}
// swiftlint:disable:next cyclomatic_complexity function_parameter_count
// swiftlint:disable:next function_parameter_count
func buildProfileChangeString(displayName: String?, previousDisplayName: String?,
avatarURLString: String?, previousAvatarURLString: String?,
member: String, memberIsYou: Bool) -> String? {
@ -122,7 +121,6 @@ struct RoomStateEventStringBuilder {
}
}
// swiftlint:disable:next cyclomatic_complexity function_body_length
func buildString(for state: OtherState, stateKey: String?, sender: TimelineItemSender, isOutgoing: Bool) -> String? {
let senderName = sender.displayName ?? sender.id

View File

@ -36,7 +36,6 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
self.stateEventStringBuilder = stateEventStringBuilder
}
// swiftlint:disable:next cyclomatic_complexity
func buildTimelineItem(for eventItemProxy: EventTimelineItemProxy) -> RoomTimelineItemProtocol? {
let isOutgoing = eventItemProxy.isOwn
@ -543,7 +542,6 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
// MARK: - Reply details
// swiftlint:disable:next cyclomatic_complexity
private func buildReplyToDetailsFrom(details: InReplyToDetails?) -> TimelineItemReplyDetails? {
guard let details else { return nil }

View File

@ -70,7 +70,6 @@ enum RoomTimelineItemType: Equatable {
case location(LocationRoomTimelineItem)
case poll(PollRoomTimelineItem)
// swiftlint:disable:next cyclomatic_complexity
init(item: RoomTimelineItemProtocol) {
switch item {
case let item as TextRoomTimelineItem:

View File

@ -248,7 +248,6 @@ class LoggingTests: XCTestCase {
XCTAssertFalse(content.contains(lastMessage))
}
// swiftlint:disable:next function_body_length
func testTimelineContentIsRedacted() throws {
// Given timeline items that contain text
let textAttributedString = "TextAttributed"