Skip to content

Commit 2b12759

Browse files
Adjust linter rules and linted paths (#1002)
* Remove trailing_whitespace from SwiftLint rules due to multi-line string issues * Lint everything * Rename deprecated rule --------- Co-authored-by: Alexey Alter-Pesotskiy <alex@testableapple.com>
1 parent be87931 commit 2b12759

31 files changed

+293
-280
lines changed

.swiftformat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
--rules redundantRawValues
3636
--rules redundantVoidReturnType
3737
--rules semicolons
38-
--rules sortedImports
38+
--rules sortImports
3939
--rules spaceAroundBraces
4040
--rules spaceAroundBrackets
4141
--rules spaceAroundComments
@@ -81,4 +81,4 @@
8181
--wrapcollections before-first
8282

8383
# Exclude paths
84-
--exclude Sources/StreamChatSwiftUI/Generated,Sources/StreamChatSwiftUI/StreamSwiftyGif,Sources/StreamChatSwiftUI/StreamNuke
84+
--exclude Sources/StreamChatSwiftUI/Generated,Sources/StreamChatSwiftUI/StreamSwiftyGif,Sources/StreamChatSwiftUI/StreamNuke,vendor/bundle,Pods,spm_cache,derived_data,.build

.swiftlint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ excluded:
55
- Sources/StreamChatSwiftUI/Generated
66
- Sources/StreamChatSwiftUI/StreamSwiftyGif
77
- Sources/StreamChatSwiftUI/StreamNuke
8+
- vendor/bundle
89

910
only_rules:
1011
- attribute_name_spacing
@@ -43,7 +44,6 @@ only_rules:
4344
- trailing_comma
4445
- trailing_newline
4546
- trailing_semicolon
46-
- trailing_whitespace
4747
- unneeded_break_in_switch
4848
- unneeded_override
4949
- unused_closure_parameter
@@ -55,8 +55,5 @@ only_rules:
5555
multiline_arguments:
5656
only_enforce_after_first_closure_on_first_line: true
5757

58-
trailing_whitespace:
59-
ignores_empty_lines: true
60-
6158
file_name_no_space:
6259
severity: error

Scripts/GenerateSPMFileLists.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func sourceFileList(at url: URL) -> [String] {
3434
let basePathRange = path.range(of: url.path + "/")!
3535
return String(path[basePathRange.upperBound...])
3636
}
37-
.filter { $0.hasSuffix("_Tests.swift") || $0.hasSuffix("_Mock.swift") || $0.contains("__Snapshots__")}
37+
.filter { $0.hasSuffix("_Tests.swift") || $0.hasSuffix("_Mock.swift") || $0.contains("__Snapshots__") }
3838

3939
return sourceFiles
4040
}
@@ -59,8 +59,6 @@ newGeneratedContent += "] }\n"
5959

6060
newGeneratedContent += "\n"
6161

62-
63-
6462
// StreamChatUI excluded source files
6563
let streamChatUIExcludedFiles = sourceFileList(at: URL(string: "Sources/StreamChatUI")!)
6664
newGeneratedContent += "var streamChatUIFilesExcluded: [String] { [\n"

StreamChatSwiftUITestsApp/AppDelegate.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
import SwiftUI
66

77
class AppDelegate: NSObject, UIApplicationDelegate {
8-
9-
func application(_ application: UIApplication,
10-
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
8+
func application(
9+
_ application: UIApplication,
10+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
11+
) -> Bool {
1112
disableAnimations()
1213
registerForPushNotifications()
1314
UNUserNotificationCenter.current().delegate = NotificationsHandler.shared
1415
return true
1516
}
1617

17-
func application(_ application: UIApplication,
18-
configurationForConnecting connectingSceneSession: UISceneSession,
19-
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
18+
func application(
19+
_ application: UIApplication,
20+
configurationForConnecting connectingSceneSession: UISceneSession,
21+
options: UIScene.ConnectionOptions
22+
) -> UISceneConfiguration {
2023
let sceneConfig = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
2124
sceneConfig.delegateClass = SceneDelegate.self
2225
return sceneConfig
@@ -44,13 +47,14 @@ class AppDelegate: NSObject, UIApplicationDelegate {
4447
}
4548

4649
func application(
47-
_ application: UIApplication,
48-
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
50+
_ application: UIApplication,
51+
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
4952
) {
5053
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
5154
let token = tokenParts.joined()
5255
print("Device Token: \(token)")
5356
}
57+
5458
func application(
5559
_ application: UIApplication,
5660
didFailToRegisterForRemoteNotificationsWithError error: Error

StreamChatSwiftUITestsApp/CustomChannelHeader.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import StreamChatSwiftUI
77
import SwiftUI
88

99
public struct CustomChannelHeader: ToolbarContent {
10-
1110
@Injected(\.fonts) var fonts
1211
@Injected(\.images) var images
1312
@Injected(\.colors) var colors
@@ -36,7 +35,6 @@ public struct CustomChannelHeader: ToolbarContent {
3635
}
3736

3837
struct CustomChannelModifier: ChannelListHeaderViewModifier {
39-
4038
@Injected(\.chatClient) var chatClient
4139

4240
var title: String

StreamChatSwiftUITestsApp/InternetConnectionMonitor_Mock.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import Foundation
66

7-
//#if TESTS
7+
// #if TESTS
88
@testable import StreamChat
99

1010
final class InternetConnectionMonitor_Mock: InternetConnectionMonitor {
@@ -19,6 +19,6 @@ final class InternetConnectionMonitor_Mock: InternetConnectionMonitor {
1919
self.status = status
2020
delegate?.internetConnectionStatusDidChange(status: status)
2121
}
22-
2322
}
24-
//#endif
23+
24+
// #endif

StreamChatSwiftUITestsApp/StartPage.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// Copyright © 2025 Stream.io Inc. All rights reserved.
33
//
44

5-
import SwiftUI
65
import StreamChat
76
import StreamChatSwiftUI
7+
import SwiftUI
88

99
struct StartPage: View {
10-
1110
@State var streamChat: StreamChat?
1211
@State var chatShown = false
1312
@ObservedObject var appState = AppState.shared
@@ -67,8 +66,8 @@ struct StartPage: View {
6766
streamChat = StreamChat(chatClient: chatClient)
6867

6968
chatClient.connectUser(
70-
userInfo: .init(id: credentials.id, name: credentials.name, imageURL: credentials.avatarURL),
71-
token: token
69+
userInfo: .init(id: credentials.id, name: credentials.name, imageURL: credentials.avatarURL),
70+
token: token
7271
) { error in
7372
if let error = error {
7473
log.error("connecting the user failed \(error)")
@@ -79,7 +78,6 @@ struct StartPage: View {
7978
}
8079

8180
class DemoAppFactory: ViewFactory {
82-
8381
@Injected(\.chatClient) public var chatClient
8482

8583
private init() {}

StreamChatSwiftUITestsApp/StreamChatSwiftUITestsAppApp.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import SwiftUI
77

88
@main
99
struct StreamChatSwiftUITestsAppApp: App {
10-
1110
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
1211

1312
var body: some Scene {
@@ -18,7 +17,6 @@ struct StreamChatSwiftUITestsAppApp: App {
1817
}
1918

2019
class AppState: ObservableObject, Equatable {
21-
2220
static func == (lhs: AppState, rhs: AppState) -> Bool {
2321
lhs.userState == rhs.userState
2422
}

StreamChatSwiftUITestsApp/StreamChatWrapper.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44

55
import Foundation
66
#if TESTS
7-
@testable import StreamChat
87
import OHHTTPStubs
8+
@testable import StreamChat
99
#else
1010
import StreamChat
1111
#endif
1212
import StreamChatSwiftUI
1313
import UIKit
1414

1515
final class StreamChatWrapper {
16-
1716
@Injected(\.chatClient) var client
1817

1918
static let shared = StreamChatWrapper()
@@ -26,9 +25,11 @@ final class StreamChatWrapper {
2625
let baseURL = self.client.config.baseURL.restAPIBaseURL.absoluteString
2726
return request.url?.absoluteString.contains(baseURL) ?? false
2827
}, withStubResponse: { _ -> HTTPStubsResponse in
29-
let error = NSError(domain: "NSURLErrorDomain",
30-
code: -1009,
31-
userInfo: nil)
28+
let error = NSError(
29+
domain: "NSURLErrorDomain",
30+
code: -1009,
31+
userInfo: nil
32+
)
3233
return HTTPStubsResponse(error: error)
3334
})
3435

@@ -51,5 +52,4 @@ final class StreamChatWrapper {
5152
}
5253
#endif
5354
}
54-
5555
}

StreamChatSwiftUITestsApp/UserCredentials.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public struct UserCredentials {
1818
}
1919

2020
extension UserCredentials {
21-
2221
static func builtInUsersByID(id: String) -> UserCredentials? {
2322
mock
2423
}
2524

26-
static let mock: UserCredentials = UserCredentials(id: "luke_skywalker",
27-
name: "Luke Skywalker",
28-
avatarURL: URL(string: "https://vignette.wikia.nocookie.net/starwars/images/2/20/LukeTLJ.jpg")!,
29-
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoibHVrZV9za3l3YWxrZXIifQ.b6EiC8dq2AHk0JPfI-6PN-AM9TVzt8JV-qB1N9kchlI",
30-
birthLand: "Tatooine")
31-
25+
static let mock: UserCredentials = UserCredentials(
26+
id: "luke_skywalker",
27+
name: "Luke Skywalker",
28+
avatarURL: URL(string: "https://vignette.wikia.nocookie.net/starwars/images/2/20/LukeTLJ.jpg")!,
29+
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoibHVrZV9za3l3YWxrZXIifQ.b6EiC8dq2AHk0JPfI-6PN-AM9TVzt8JV-qB1N9kchlI",
30+
birthLand: "Tatooine"
31+
)
3232
}

0 commit comments

Comments
 (0)