Skip to content

Commit e972ff3

Browse files
Add SwiftLint, fix swiftlint issues
1 parent ede1182 commit e972ff3

16 files changed

+68
-22
lines changed

OktaLogger.playground/Pages/FileLogger.xcplaygroundpage/Contents.swift

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/*
2+
* Copyright (c) 2020-Present, Okta, Inc. and/or its affiliates. All rights reserved.
3+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4+
*
5+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6+
* Unless required by applicable law or agreed to in writing, software
7+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
*
10+
* See the License for the specific language governing permissions and limitations under the License.
11+
*/
12+
113
import UIKit
214
import OktaLogger
315

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1+
/*
2+
* Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
3+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4+
*
5+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6+
* Unless required by applicable law or agreed to in writing, software
7+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
*
10+
* See the License for the specific language governing permissions and limitations under the License.
11+
*/
12+
13+
114
//: # OktaLogger Documentation
215
//: - [How to Use a File Logger?](FileLogger)

OktaLogger.xcodeproj/project.pbxproj

+19
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
D5C824D12469DBF1005CF747 /* Frameworks */,
368368
D5C824D22469DBF1005CF747 /* Resources */,
369369
80DDE78E24B962C900D0E2F3 /* Embed Frameworks */,
370+
7B0C4EE7276D1DAC0033BDC6 /* SwiftLint */,
370371
);
371372
buildRules = (
372373
);
@@ -574,6 +575,24 @@
574575
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
575576
showEnvVarsInLog = 0;
576577
};
578+
7B0C4EE7276D1DAC0033BDC6 /* SwiftLint */ = {
579+
isa = PBXShellScriptBuildPhase;
580+
buildActionMask = 2147483647;
581+
files = (
582+
);
583+
inputFileListPaths = (
584+
);
585+
inputPaths = (
586+
);
587+
name = SwiftLint;
588+
outputFileListPaths = (
589+
);
590+
outputPaths = (
591+
);
592+
runOnlyForDeploymentPostprocessing = 0;
593+
shellPath = /bin/sh;
594+
shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\" --config \"${PROJECT_DIR}/.swiftlint.yml\"\n";
595+
};
577596
9ECAD1E0171C5273C443BE35 /* [CP] Embed Pods Frameworks */ = {
578597
isa = PBXShellScriptBuildPhase;
579598
buildActionMask = 2147483647;

OktaLogger/AppCenterLogger/AppCenterLogger.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import AppCenterAnalytics
1314

1415
/**

OktaLogger/FileLoggers/DDLogFileManagerCustomName.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import Foundation
1314
import CocoaLumberjack
1415

OktaLogger/FileLoggers/LumberjackLoggerDelegate.swift

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import CocoaLumberjack
1314

1415
class LumberjackLoggerDelegate: FileLoggerDelegate {

OktaLogger/FileLoggers/OktaLoggerFileLogFormatter.swift

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12-
//
13-
// OktaLoggerFileLogFormatter.swift
14-
// OktaLogger
15-
//
16-
// Created by Borys Kasianenko on 1/25/21.
17-
//
1812

1913
import Foundation
2014
import CocoaLumberjack

OktaLogger/FileLoggers/OktaLoggerFileLogger.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-Present, Okta, Inc. and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
33
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
44
*
55
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
@@ -9,6 +9,7 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import Foundation
1314

1415
@objc

OktaLogger/FileLoggers/OktaLoggerFileLoggerConfig.swift

+2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import Foundation
14+
1315
@objc
1416
public class OktaLoggerFileLoggerConfig: NSObject {
1517

OktaLogger/FirebaseCrashlyticsLogger/OktaLoggerFirebaseCrashlyticsLogger.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import FirebaseCrashlytics
1314

1415
/**
@@ -91,7 +92,7 @@ open class OktaLoggerFirebaseCrashlyticsLogger: OktaLoggerDestinationBase {
9192
let normalizedEventName = eventName.lowercased().replacingOccurrences(of: " ", with: "-")
9293
return "\(identifier).\(normalizedEventName)"
9394
}
94-
95+
9596
class func createUserInfoDict(level: OktaLoggerLogLevel,
9697
eventName: String,
9798
message: String?,
@@ -108,19 +109,19 @@ open class OktaLoggerFirebaseCrashlyticsLogger: OktaLoggerDestinationBase {
108109
"line": line,
109110
"function": funcName
110111
]
111-
112+
112113
// merge destination-level properties into userInfo (high priority)
113114
if let defaultProperties = defaultProperties as? [String: Any],
114115
!defaultProperties.isEmpty {
115116
userInfo.merge(defaultProperties) { (_, last) in last }
116117
}
117-
118+
118119
// merge log-level properties into userInfo (highest priority)
119120
if let properties = properties as? [String: Any],
120121
!properties.isEmpty {
121122
userInfo.merge(properties) { (_, last) in last }
122123
}
123-
124+
124125
return userInfo
125126
}
126127
}

OktaLogger/InstabugLogger/OktaLoggerInstabugLogger.swift

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313
import Instabug
1414

15-
/**
16-
Concrete logging class for Instabug.
17-
*/
15+
/// Concrete logging destination for Instabug
1816
open class OktaLoggerInstabugLogger: OktaLoggerDestinationBase {
1917

2018
override open func log(level: OktaLoggerLogLevel, eventName: String, message: String?, properties: [AnyHashable: Any]?, file: String, line: NSNumber, funcName: String) {
@@ -47,7 +45,7 @@ open class OktaLoggerInstabugLogger: OktaLoggerDestinationBase {
4745
}
4846
}
4947

50-
open override func stringValue(level: OktaLoggerLogLevel, eventName: String, message: String?, file: String, line: NSNumber, funcName: String) -> String {
48+
override open func stringValue(level: OktaLoggerLogLevel, eventName: String, message: String?, file: String, line: NSNumber, funcName: String) -> String {
5149
let fileLogString = file.split(separator: "/").last ?? ""
5250
let messageLogString: String = {
5351
guard let message = message else {

OktaLogger/OktaLogger.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import Foundation
1314

1415
/**
@@ -136,7 +137,7 @@ open class OktaLogger: NSObject, OktaLoggerProtocol {
136137
self.loggingDestinations = destinationDict
137138
}
138139

139-
public convenience override init() {
140+
override public convenience init() {
140141
self.init(destinations: [])
141142
}
142143

OktaLogger/OktaLoggerDestination.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-Present, Okta, Inc. and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021-Present, Okta, Inc. and/or its affiliates. All rights reserved.
33
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
44
*
55
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
@@ -9,6 +9,7 @@
99
*
1010
* See the License for the specific language governing permissions and limitations under the License.
1111
*/
12+
1213
import Foundation
1314

1415
/**

OktaLoggerTests/Helpers/FileTestsHelper.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class FileTestsHelper {
5353
try? FileManager.default.removeItem(at: FileTestsHelper.testLogsFolder)
5454
}
5555

56-
static private var testLogsFolder: URL {
56+
// swiftlint:disable force_unwrapping
57+
private static var testLogsFolder: URL {
5758
return FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
5859
.appendingPathComponent("TestLogs", isDirectory: true)
5960
}

OktaLoggerTests/OktaLoggerFileLoggerMultithreadingTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class OktaLoggerFileLoggerMultithreadingTests: XCTestCase {
7070
}
7171

7272
wait(for: [testFinishExpectation], timeout: defaultTimeout)
73-
73+
7474
let purgeExpectation = expectation(description: "Purge logs from main thread")
7575
lumberjackDelegate.purgeLogs()
7676
DispatchQueue.main.async {

OktaLoggerTests/OktaLoggerFirebaseLoggerTests.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import XCTest
1313
@testable import OktaLogger
1414

1515
class OktaLoggerFirebaseLoggerTests: XCTestCase {
16-
16+
1717
/// Verify that the userInfo dict is created as expected
1818
/// defaultProperties and logged properties should be merged into the userInfo dict in correct priority
1919
func testUserInfoMerge() {
@@ -22,7 +22,7 @@ class OktaLoggerFirebaseLoggerTests: XCTestCase {
2222
let pushToken = UUID().uuidString
2323
let properties = [
2424
"pushToken": pushToken,
25-
"override" : "SUCCESS"
25+
"override": "SUCCESS"
2626
]
2727
let appInstanceId = UUID().uuidString
2828
let file = UUID().uuidString
@@ -41,7 +41,7 @@ class OktaLoggerFirebaseLoggerTests: XCTestCase {
4141
file: file,
4242
line: line,
4343
funcName: funcName)
44-
44+
4545
XCTAssertEqual(userInfo["eventName"] as? String, eventName)
4646
XCTAssertEqual(userInfo["message"] as? String, message)
4747
XCTAssertEqual(userInfo["pushToken"] as? String, pushToken)

0 commit comments

Comments
 (0)