Skip to content

Commit a9b8845

Browse files
committed
Add Linting to Build Phase + Fix Linting Errors
Also added swiftlint.yml to IOSExample project root in order to pick up rule modifications.
1 parent 5f9628b commit a9b8845

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed

XMTPiOSExample/.swiftlint.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
excluded:
2+
- Sources/XMTP/Proto
3+
4+
disabled_rules: # rule identifiers turned on by default to exclude from running
5+
- type_name
6+
- identifier_name
7+
- multiple_closures_with_trailing_closure
8+
- cyclomatic_complexity
9+
- trailing_comma
10+
- opening_brace
11+
- nesting
12+
- type_body_length
13+
- file_length
14+
15+
opt_in_rules:
16+
- force_unwrapping
17+
18+
force_unwrapping:
19+
severity: error
20+
21+
line_length: 500
22+
23+
custom_rules:
24+
no_optional_try: # rule identifier
25+
included:
26+
- ".*\\.swift" # regex that defines paths to include during linting. optional.
27+
excluded:
28+
- ".*Tests?\\.swift" # regex that defines paths to exclude during linting. optional
29+
name: "No optional try" # rule name. optional.
30+
regex: try[\\?]
31+
capture_group: 0 # number of regex capture group to highlight the rule violation at. optional.
32+
message: "Handle this error instead of doing this.." # violation message. optional.
33+
severity: error # violation severity. optional.
34+
#match_kinds:# SyntaxKinds to match. optional.
35+
# - comment
36+
# - identifier

XMTPiOSExample/XMTPiOSExample.xcodeproj/project.pbxproj

+23
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
A628198B292DC825004B9117 /* Sources */,
239239
A628198C292DC825004B9117 /* Frameworks */,
240240
A628198D292DC825004B9117 /* Resources */,
241+
636E6B4E2B890E7300B43B62 /* Code Linter: SwiftLint */,
241242
A65F0701297B5BCC00C3C76E /* Embed Foundation Extensions */,
242243
);
243244
buildRules = (
@@ -344,6 +345,28 @@
344345
};
345346
/* End PBXResourcesBuildPhase section */
346347

348+
/* Begin PBXShellScriptBuildPhase section */
349+
636E6B4E2B890E7300B43B62 /* Code Linter: SwiftLint */ = {
350+
isa = PBXShellScriptBuildPhase;
351+
alwaysOutOfDate = 1;
352+
buildActionMask = 2147483647;
353+
files = (
354+
);
355+
inputFileListPaths = (
356+
);
357+
inputPaths = (
358+
);
359+
name = "Code Linter: SwiftLint";
360+
outputFileListPaths = (
361+
);
362+
outputPaths = (
363+
);
364+
runOnlyForDeploymentPostprocessing = 0;
365+
shellPath = /bin/sh;
366+
shellScript = "if [ $ACTION != \"indexbuild\" ]; then\n if which swiftlint >/dev/null; then\n swiftlint lint --strict\n else \n echo \"warning: SwiftLint not installed, install it via Homebrew according to README instructions\"\n fi\nfi\n\n";
367+
};
368+
/* End PBXShellScriptBuildPhase section */
369+
347370
/* Begin PBXSourcesBuildPhase section */
348371
A628198B292DC825004B9117 /* Sources */ = {
349372
isa = PBXSourcesBuildPhase;

XMTPiOSExample/XMTPiOSExample/Account/WalletConnection.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import UIKit
1010
import WalletConnectSwift
1111
import web3
1212
import XMTPiOS
13-
import UIKit
1413

1514
extension WCURL {
1615
var asURL: URL {
@@ -183,7 +182,7 @@ class WCWalletConnection: WalletConnection, WalletConnectSwift.ClientDelegate {
183182
func client(_: WalletConnectSwift.Client, didFailToConnect _: WalletConnectSwift.WCURL) {}
184183

185184
func client(_: WalletConnectSwift.Client, didConnect session: WalletConnectSwift.Session) {
186-
// TODO: Cache session
185+
// Future Implementation Cache session
187186
self.session = session
188187
}
189188

XMTPiOSExample/XMTPiOSExample/Views/LoginView.swift

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ struct LoginView: View {
181181
}
182182
.store(in: &publishers)
183183
}
184+
// swiftlint:enable function_body_length
184185

185186
var body: some View {
186187
ModalWrapper()

XMTPiOSExample/XMTPiOSExample/Views/MessageCellView.swift

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct MessageTextView: View {
6060
} catch {
6161
return message.fallbackContent
6262
}
63-
// swiftlint:enable force_try
6463
}
6564

6665
var background: Color {

XMTPiOSExample/XMTPiOSExample/Views/MessageListView.swift

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct MessageListView: View {
4343
struct MessageListView_Previews: PreviewProvider {
4444
static var previews: some View {
4545
PreviewClientProvider { client in
46+
// swiftlint: disable comma
4647
MessageListView(
4748
myAddress: "0x00", messages: [
4849
DecodedMessage.preview(client: client, topic: "foo", body: "Hello", senderAddress: "0x00", sent: Date().addingTimeInterval(-10)),
@@ -53,6 +54,7 @@ struct MessageListView_Previews: PreviewProvider {
5354
DecodedMessage.preview(client: client, topic: "foo",body: "🧐", senderAddress: "0x00", sent: Date().addingTimeInterval(-5)),
5455
]
5556
)
57+
// swiftlint: enable comma
5658
}
5759
}
5860
}

0 commit comments

Comments
 (0)