Skip to content

Commit 218e875

Browse files
[CI] Improve linters and git hooks (#880)
1 parent 3e42325 commit 218e875

File tree

236 files changed

+122
-639
lines changed

Some content is hidden

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

236 files changed

+122
-639
lines changed

.github/workflows/cron-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
- uses: actions/checkout@v4.1.1
143143
- uses: ./.github/actions/bootstrap
144144
- run: bundle exec fastlane rubocop
145-
- run: ./Scripts/run-linter.sh
145+
- run: bundle exec fastlane run_swift_format strict:true
146146
- run: bundle exec fastlane pod_lint
147147

148148
slack:

.github/workflows/smoke-checks.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,11 @@ jobs:
5353
steps:
5454
- uses: actions/checkout@v4.1.1
5555
- uses: ./.github/actions/bootstrap
56-
- name: Run Danger
57-
run: bundle exec fastlane lint_pr
58-
- name: Run Fastlane Linting
59-
run: bundle exec fastlane rubocop
60-
- name: Run SwiftFormat Linting
61-
run: ./Scripts/run-linter.sh
62-
- name: Run Podspec Linting
56+
- run: bundle exec fastlane lint_pr
57+
- run: bundle exec fastlane rubocop
58+
- run: bundle exec fastlane run_swift_format strict:true
59+
- run: bundle exec fastlane pod_lint
6360
if: startsWith(github.event.pull_request.head.ref, 'release/')
64-
run: bundle exec fastlane pod_lint
6561

6662
build-xcode15:
6763
name: Build SDKs (Xcode 15)

.swiftformat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
--disable redundantType
77
--disable extensionAccessControl
88
--disable andOperator
9-
--disable blankLinesAtStartOfScope
9+
--disable hoistPatternLet
10+
--disable typeSugar
11+
12+
--disable redundantGet # it removes get async throws from getters
1013

1114
# Rules inferred from Swift Standard Library:
1215
--disable anyObjectProtocol, wrapMultilineStatementBraces
@@ -18,7 +21,6 @@
1821
--commas inline
1922
--trimwhitespace nonblank-lines
2023
--stripunusedargs closure-only
21-
--maxwidth 132
2224

2325
--binarygrouping 4,7
2426
--octalgrouping none

.swiftlint.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
included:
2+
- Sources
3+
- DemoAppSwiftUI
4+
excluded:
5+
- Sources/StreamChatSwiftUI/Generated
6+
- Sources/StreamChatSwiftUI/StreamSwiftyGif
7+
- Sources/StreamChatSwiftUI/StreamNuke
8+
9+
only_rules:
10+
# Currently enabled autocorrectable rules
11+
- attribute_name_spacing
12+
- closing_brace
13+
- colon
14+
- comma
15+
- comment_spacing
16+
- control_statement
17+
- custom_rules
18+
- duplicate_imports
19+
- empty_enum_arguments
20+
- empty_parameters
21+
- empty_parentheses_with_trailing_closure
22+
- explicit_init
23+
- joined_default_parameter
24+
- leading_whitespace
25+
- legacy_cggeometry_functions
26+
- legacy_constant
27+
- legacy_constructor
28+
- legacy_nsgeometry_functions
29+
- mark
30+
- no_space_in_method_call
31+
- prefer_type_checking
32+
- private_over_fileprivate
33+
- private_unit_test
34+
- protocol_property_accessors_order
35+
- redundant_discardable_let
36+
- redundant_objc_attribute
37+
- redundant_optional_initialization
38+
- redundant_sendable
39+
- redundant_void_return
40+
- return_arrow_whitespace
41+
- syntactic_sugar
42+
- toggle_bool
43+
- trailing_comma
44+
- trailing_newline
45+
- trailing_semicolon
46+
- trailing_whitespace
47+
- unneeded_break_in_switch
48+
- unneeded_override
49+
- unused_closure_parameter
50+
- unused_control_flow_label
51+
- unused_import
52+
- vertical_whitespace
53+
- void_return
54+
55+
trailing_whitespace:
56+
ignores_empty_lines: true

DemoAppSwiftUI/AppDelegate.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import SwiftUI
1010
import UIKit
1111

1212
class AppDelegate: NSObject, UIApplicationDelegate {
13-
1413
var streamChat: StreamChat?
1514

1615
var chatClient: ChatClient = {

DemoAppSwiftUI/AppleMessageComposerView.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import SwiftUI
88

99
@available(iOS 15.0, *)
1010
struct AppleMessageComposerView<Factory: ViewFactory>: View, KeyboardReadable {
11-
1211
@State var text = ""
1312
@State var shouldShow = false
1413

@@ -214,7 +213,7 @@ struct BlurredBackground: View {
214213
}
215214

216215
struct HeightPreferenceKey: PreferenceKey {
217-
static var defaultValue: CGFloat? = nil
216+
static var defaultValue: CGFloat?
218217

219218
static func reduce(value: inout CGFloat?, nextValue: () -> CGFloat?) {
220219
value = value ?? nextValue()
@@ -241,7 +240,6 @@ struct ComposerAction: Equatable, Identifiable {
241240

242241
@available(iOS 15.0, *)
243242
struct ComposerActionsView: View {
244-
245243
@ObservedObject var viewModel: MessageComposerViewModel
246244

247245
@State var composerActions: [ComposerAction] = []
@@ -346,7 +344,6 @@ struct ComposerActionsView: View {
346344
}
347345

348346
struct ComposerActionView: View {
349-
350347
private let imageSize: CGFloat = 34
351348

352349
var composerAction: ComposerAction

DemoAppSwiftUI/ChannelHeader/BlockedUsersView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import StreamChatSwiftUI
66
import SwiftUI
77

88
struct BlockedUsersView: View {
9-
109
@StateObject var viewModel = BlockedUsersViewModel()
1110

1211
var body: some View {

DemoAppSwiftUI/ChannelHeader/BlockedUsersViewModel.swift

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

99
class BlockedUsersViewModel: ObservableObject {
10-
1110
@Injected(\.chatClient) var chatClient
1211

1312
@Published var blockedUsers = [ChatUser]()

DemoAppSwiftUI/ChannelHeader/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
@@ -51,7 +50,6 @@ public struct CustomChannelHeader: ToolbarContent {
5150
}
5251

5352
struct CustomChannelModifier: ChannelListHeaderViewModifier {
54-
5553
@Injected(\.chatClient) var chatClient
5654

5755
var title: String

DemoAppSwiftUI/ChannelHeader/NewChatView.swift

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

99
struct NewChatView: View, KeyboardReadable {
10-
1110
@Injected(\.fonts) var fonts
1211
@Injected(\.colors) var colors
1312

@@ -106,7 +105,6 @@ struct NewChatView: View, KeyboardReadable {
106105
}
107106

108107
struct TabBarVisibilityModifier: ViewModifier {
109-
110108
func body(content: Content) -> some View {
111109
if #available(iOS 16.0, *) {
112110
content.toolbar(.hidden, for: .tabBar)
@@ -117,7 +115,6 @@ struct TabBarVisibilityModifier: ViewModifier {
117115
}
118116

119117
struct SelectedUserView: View {
120-
121118
@Injected(\.colors) var colors
122119

123120
var user: ChatUser
@@ -140,7 +137,6 @@ struct SelectedUserView: View {
140137
}
141138

142139
struct SearchUsersView: View {
143-
144140
@StateObject var viewModel: NewChatViewModel
145141

146142
var body: some View {
@@ -160,7 +156,6 @@ struct SearchUsersView: View {
160156
}
161157

162158
struct VerticallyCenteredView<Content: View>: View {
163-
164159
var content: () -> Content
165160

166161
var body: some View {
@@ -173,7 +168,6 @@ struct VerticallyCenteredView<Content: View>: View {
173168
}
174169

175170
struct CreateGroupButton: View {
176-
177171
@Injected(\.colors) var colors
178172
@Injected(\.fonts) var fonts
179173

@@ -201,7 +195,6 @@ struct CreateGroupButton: View {
201195
}
202196

203197
struct ChatUserView: View {
204-
205198
@Injected(\.colors) var colors
206199
@Injected(\.fonts) var fonts
207200

@@ -235,7 +228,6 @@ struct ChatUserView: View {
235228
}
236229

237230
struct UsersHeaderView: View {
238-
239231
@Injected(\.colors) var colors
240232
@Injected(\.fonts) var fonts
241233

0 commit comments

Comments
 (0)