Skip to content

Commit 8d96956

Browse files
Merge pull request #286 from pusher/feature/281-add-swiftlint-support
Add Swiftint support
2 parents a447e7d + 35341cf commit 8d96956

Some content is hidden

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

49 files changed

+648
-469
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ fastlane/screenshots
6161
.swift-version
6262
test_push.rb
6363
SwiftLibExampleCertificate.pem
64+
65+
# macOS
66+
67+
.DS_Store

.swiftlint.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
excluded:
2+
- Carthage
3+
- Package.swift
4+
5+
identifier_name:
6+
excluded:
7+
- id
8+
- ex
9+
- to
10+
- ws
11+
12+
# This generates a compiler error if more than this many SwiftLint warnings are present
13+
# (This threshold can become more restrictive as remaining warnings are resolved via refactoring)
14+
warning_threshold: 25

Consumption-Tests/.swiftlint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
disabled_rules:
2+
- line_length

Consumption-Tests/Shared/Swift/ViewController+Extensions.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct DebugConsoleMessage: Codable {
2121
}
2222

2323
extension ViewController {
24-
24+
2525
func makeAndLaunchPusher() -> Pusher {
2626

2727
// Only use your secret here for testing or if you're sure that there's security risk
@@ -38,7 +38,7 @@ extension ViewController {
3838
pusher.connect()
3939

4040
// bind to all events globally
41-
let _ = pusher.bind(eventCallback: { (event: PusherEvent) in
41+
_ = pusher.bind(eventCallback: { (event: PusherEvent) in
4242
var message = "Received event: '\(event.eventName)'"
4343

4444
if let channel = event.channelName {
@@ -58,7 +58,7 @@ extension ViewController {
5858
let myChannel = pusher.subscribe("my-channel")
5959

6060
// bind a callback to event "my-event" on that channel
61-
let _ = myChannel.bind(eventName: "my-event", eventCallback: { (event: PusherEvent) in
61+
_ = myChannel.bind(eventName: "my-event", eventCallback: { (event: PusherEvent) in
6262

6363
// convert the data string to type data for decoding
6464
guard let json: String = event.data,
@@ -88,13 +88,13 @@ extension ViewController {
8888

8989
// triggers a client event on that channel
9090
chan.trigger(eventName: "client-test", data: ["test": "some value"])
91-
91+
9292
return pusher
9393
}
9494
}
9595

9696
extension ViewController: PusherDelegate {
97-
97+
9898
// PusherDelegate methods
9999

100100
func changedConnectionState(from old: ConnectionState, to new: ConnectionState) {

Consumption-Tests/Shared/Swift/iOS/AppDelegate.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
66
var window: UIWindow?
77

88
#if swift(>=4.2)
9-
10-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
9+
10+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
1111

1212
return true
1313
}
14-
14+
1515
#else
16-
17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
16+
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
1818

1919
return true
2020
}
21-
21+
2222
#endif
23-
23+
2424
}

Consumption-Tests/Shared/Swift/iOS/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class ViewController: UIViewController {
2121
super.viewDidLoad()
2222
self.pusher = makeAndLaunchPusher()
2323
}
24-
24+
2525
}

Consumption-Tests/Shared/Swift/macOS/AppDelegate.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import Cocoa
33
@NSApplicationMain
44
class AppDelegate: NSObject, NSApplicationDelegate {
55

6-
7-
86
func applicationDidFinishLaunching(_ aNotification: Notification) {
97
// Insert code here to initialize your application
108
}
@@ -13,6 +11,4 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1311
// Insert code here to tear down your application
1412
}
1513

16-
1714
}
18-

Consumption-Tests/Shared/Swift/tvOS/AppDelegate.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
21
import UIKit
32

43
@UIApplicationMain
54
class AppDelegate: UIResponder, UIApplicationDelegate {
65

76
var window: UIWindow?
87

9-
108
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
119
// Override point for customization after application launch.
1210
return true
@@ -29,6 +27,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2927
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
3028
}
3129

32-
3330
}
34-

Consumption-Tests/Shared/Swift/tvOS/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ class ViewController: UIViewController {
2121
super.viewDidLoad()
2222
self.pusher = makeAndLaunchPusher()
2323
}
24-
24+
2525
}

PusherSwift.xcodeproj/project.pbxproj

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@
358358
33831C861A9CF61600B124F1 /* Headers */,
359359
33831C871A9CF61600B124F1 /* Resources */,
360360
50355EA8A07B4B8038A4DDF1 /* Frameworks */,
361+
5333AD0A24FE4A8C006E8DF0 /* Run SwiftLint autocorrect */,
362+
5333AD0824F928F1006E8DF0 /* Run SwiftLint */,
361363
);
362364
buildRules = (
363365
);
@@ -396,6 +398,8 @@
396398
73D8A1F72435E5F3001FDE05 /* Headers */,
397399
73D8A1F92435E5F3001FDE05 /* Resources */,
398400
73D8A1FA2435E5F3001FDE05 /* Frameworks */,
401+
5333AD0B24FE4AAC006E8DF0 /* Run SwiftLint autocorrect */,
402+
5333AD0924F92916006E8DF0 /* Run SwiftLint */,
399403
);
400404
buildRules = (
401405
);
@@ -520,6 +524,78 @@
520524
shellPath = /bin/sh;
521525
shellScript = "case \"$PLATFORM_NAME\" in\nmacosx) plat=Mac;;\niphone*) plat=iOS;;\nwatch*) plat=watchOS;;\ntv*) plat=tvOS;;\nappletv*) plat=tvOS;;\n*) echo \"error: Unknown PLATFORM_NAME: $PLATFORM_NAME\"; exit 1;;\nesac\nfor (( n = 0; n < SCRIPT_INPUT_FILE_COUNT; n++ )); do\nVAR=SCRIPT_INPUT_FILE_$n\nframework=$(basename \"${!VAR}\")\nexport SCRIPT_INPUT_FILE_$n=\"$SRCROOT\"/Carthage/Build/$plat/\"$framework\".framework\ndone\n\n/usr/local/bin/carthage copy-frameworks || exit\n\nfor (( n = 0; n < SCRIPT_INPUT_FILE_COUNT; n++ )); do\nVAR=SCRIPT_INPUT_FILE_$n\nsource=${!VAR}.dSYM\ndest=${BUILT_PRODUCTS_DIR}/$(basename \"$source\")\nditto \"$source\" \"$dest\" || exit\ndone\n";
522526
};
527+
5333AD0824F928F1006E8DF0 /* Run SwiftLint */ = {
528+
isa = PBXShellScriptBuildPhase;
529+
buildActionMask = 2147483647;
530+
files = (
531+
);
532+
inputFileListPaths = (
533+
);
534+
inputPaths = (
535+
);
536+
name = "Run SwiftLint";
537+
outputFileListPaths = (
538+
);
539+
outputPaths = (
540+
);
541+
runOnlyForDeploymentPostprocessing = 0;
542+
shellPath = /bin/sh;
543+
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
544+
};
545+
5333AD0924F92916006E8DF0 /* Run SwiftLint */ = {
546+
isa = PBXShellScriptBuildPhase;
547+
buildActionMask = 2147483647;
548+
files = (
549+
);
550+
inputFileListPaths = (
551+
);
552+
inputPaths = (
553+
);
554+
name = "Run SwiftLint";
555+
outputFileListPaths = (
556+
);
557+
outputPaths = (
558+
);
559+
runOnlyForDeploymentPostprocessing = 0;
560+
shellPath = /bin/sh;
561+
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
562+
};
563+
5333AD0A24FE4A8C006E8DF0 /* Run SwiftLint autocorrect */ = {
564+
isa = PBXShellScriptBuildPhase;
565+
buildActionMask = 2147483647;
566+
files = (
567+
);
568+
inputFileListPaths = (
569+
);
570+
inputPaths = (
571+
);
572+
name = "Run SwiftLint autocorrect";
573+
outputFileListPaths = (
574+
);
575+
outputPaths = (
576+
);
577+
runOnlyForDeploymentPostprocessing = 0;
578+
shellPath = /bin/sh;
579+
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
580+
};
581+
5333AD0B24FE4AAC006E8DF0 /* Run SwiftLint autocorrect */ = {
582+
isa = PBXShellScriptBuildPhase;
583+
buildActionMask = 2147483647;
584+
files = (
585+
);
586+
inputFileListPaths = (
587+
);
588+
inputPaths = (
589+
);
590+
name = "Run SwiftLint autocorrect";
591+
outputFileListPaths = (
592+
);
593+
outputPaths = (
594+
);
595+
runOnlyForDeploymentPostprocessing = 0;
596+
shellPath = /bin/sh;
597+
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
598+
};
523599
73D8A2222435F24E001FDE05 /* Copy Carthage Frameworks */ = {
524600
isa = PBXShellScriptBuildPhase;
525601
buildActionMask = 2147483647;

0 commit comments

Comments
 (0)