Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.

Commit 0da4f4f

Browse files
committed
Fix SwiftLint warning and error
1 parent 562884e commit 0da4f4f

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

Lib/StudyplusSDK/Studyplus.swift

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ final public class Studyplus {
9595
/// Studyplusアプリとの連携を解除します。
9696
public func logout() {
9797

98-
let k = keychain()
98+
let chain = keychain()
9999
do {
100-
try k.remove(usernameStoreKey)
101-
try k.remove(accessTokenStoreKey)
100+
try chain.remove(usernameStoreKey)
101+
try chain.remove(accessTokenStoreKey)
102102
} catch {
103103
}
104104
}
@@ -178,16 +178,23 @@ final public class Studyplus {
178178
})
179179
}
180180

181-
/// It is responsible for processing custom URL scheme when it came back from the authorization / login screen of Stuudyplus app.
181+
/// It is responsible for processing custom URL scheme
182+
/// when it came back from the authorization / login screen of Stuudyplus app.
182183
/// After handling openURL method in AppDelegate, pass the url parameter to this method.
183184
/// If the URL is passed by Studyplus application, calls the callback method of the delegate object.
184185
///
185186
/// Studyplusアプリの認可・ログイン画面から戻ってきた時のカスタムURLスキーム処理を担当します。
186187
/// AppDelegateでopenURLをハンドリングしてから、このメソッドにurlを渡して委譲してください。
187188
/// Studyplusアプリ関連のURLであれば、delegateオブジェクトのコールバックメソッドを呼び出します。
188189
///
189-
/// - Parameter appDelegateUrl: The parameter of AppDelegate#openURL method. AppDelegate#openURLメソッドで受け取ったurlパラメータをそのまま渡して下さい。
190-
/// - Returns: If the url is supported by StudyplusSDK, returns true. The valid URL has a __[studyplus-{consumerKey}]__ scheme, and right pathComponents and host. 渡されたurlがStudyplusSDKで対応すべきURL(スキームが __[studyplus-{consumerKey}]__ であり、host/pathComponentsが想定内であるもの)であれば true、それ以外は false を返します。
190+
/// - Parameter appDelegateUrl:
191+
/// The parameter of AppDelegate#openURL method.
192+
/// AppDelegate#openURLメソッドで受け取ったurlパラメータをそのまま渡して下さい。
193+
/// - Returns:
194+
/// If the url is supported by StudyplusSDK, returns true.
195+
/// The valid URL has a __[studyplus-{consumerKey}]__ scheme, and right pathComponents and host.
196+
/// 渡されたurlがStudyplusSDKで対応すべきURLであれば true、それ以外は false を返します。
197+
/// __[studyplus-{consumerKey}]__と正しいpathComponentsを持つことを確認してください。
191198
public func handle(appDelegateUrl: URL) -> Bool {
192199

193200
guard isAcceptableURL(url: appDelegateUrl) else {
@@ -201,10 +208,10 @@ final public class Studyplus {
201208
let accessToken: String = appDelegateUrl.pathComponents[2].trimmingCharacters(in: .whitespacesAndNewlines)
202209
let username: String = appDelegateUrl.pathComponents[3].trimmingCharacters(in: .whitespacesAndNewlines)
203210

204-
let k = keychain()
211+
let chain = keychain()
205212
do {
206-
try k.set(accessToken, key: accessTokenStoreKey)
207-
try k.set(username, key: usernameStoreKey)
213+
try chain.set(accessToken, key: accessTokenStoreKey)
214+
try chain.set(username, key: usernameStoreKey)
208215
delegate?.studyplusDidSuccessToLogin()
209216
} catch {
210217
delegate?.studyplusDidFailToLogin(error: .unknownReason("Could not access Keychain."))
@@ -233,7 +240,8 @@ final public class Studyplus {
233240
}
234241

235242
/// Change the consumer key and secret.
236-
/// Calling this method allows you to switch to another consumer key and secret. For example, you log in to Studyplus, log out, and post a study record.
243+
/// Calling this method allows you to switch to another consumer key and secret.
244+
/// For example, you log in to Studyplus, log out, and post a study record.
237245
/// If multiple applications are connected with Studyplus, you need to call this method.
238246
/// If there is only one connected application, you do not need to call this method.
239247
/// If multiple applications are connected with Studyplus, do not forget to set up custom URL schemes.
@@ -283,7 +291,6 @@ final public class Studyplus {
283291
}
284292

285293
private func keychain() -> Keychain {
286-
287294
let serviceName: String = "Studyplus_iOS_SDK_\(consumerKey)"
288295
return Keychain(service: serviceName)
289296
}

Lib/StudyplusSDK/StudyplusAPIRequest.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ internal struct StudyplusAPIRequest {
3535
self.accessToken = accessToken
3636
}
3737

38-
internal func post(path: String, params: [String: Any], success: @escaping (_ response: [AnyHashable: Any]) -> Void, failure: @escaping (_ error: StudyplusError) -> Void) {
38+
internal func post(path: String,
39+
params: [String: Any],
40+
success: @escaping (_ response: [AnyHashable: Any]) -> Void,
41+
failure: @escaping (_ error: StudyplusError) -> Void) {
3942

4043
start(path: path, method: "POST", body: params, success: { (response) in
4144

@@ -57,7 +60,11 @@ internal struct StudyplusAPIRequest {
5760

5861
// MARK: - private
5962

60-
private func start(path: String, method: String, body: [String: Any], success: @escaping (_ response: [AnyHashable: Any]) -> Void, failure: @escaping (_ statusCode: Int, _ response: [String: Any]?) -> Void) {
63+
private func start(path: String,
64+
method: String,
65+
body: [String: Any],
66+
success: @escaping (_ response: [AnyHashable: Any]) -> Void,
67+
failure: @escaping (_ statusCode: Int, _ response: [String: Any]?) -> Void) {
6168

6269
guard let url = buildUrl(path: path) else {
6370
failure(0, nil)

Lib/StudyplusSDK/StudyplusRecord.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
import Foundation
2828

2929
private let formatter: DateFormatter = {
30-
let f: DateFormatter = DateFormatter()
31-
f.locale = Locale(identifier: "en_US_POSIX")
32-
f.calendar = Calendar(identifier: .gregorian)
33-
f.timeZone = NSTimeZone.system
34-
return f
30+
let formatter: DateFormatter = DateFormatter()
31+
formatter.locale = Locale(identifier: "en_US_POSIX")
32+
formatter.calendar = Calendar(identifier: .gregorian)
33+
formatter.timeZone = NSTimeZone.system
34+
return formatter
3535
}()
3636

3737
private enum DateLocalePattern {
@@ -109,8 +109,10 @@ public struct StudyplusRecord {
109109
/// - recordedAt: Time the learning is ended. 学習を終えた日時。
110110
/// - amount: The amount of learning. 学習量。
111111
/// - comment: Studyplus timeline comment. Studyplusのタイムライン上で表示されるコメント。
112-
public init(duration: Double, recordedAt: Date = Date(), amount: StudyplusRecordAmount? = nil, comment: String? = nil) {
113-
112+
public init(duration: Double,
113+
recordedAt: Date = Date(),
114+
amount: StudyplusRecordAmount? = nil,
115+
comment: String? = nil) {
114116
self.duration = duration
115117
self.recordedAt = recordedAt
116118
self.amount = amount

0 commit comments

Comments
 (0)