mirror of
https://github.com/CocoaLumberjack/CocoaLumberjack.git
synced 2026-05-07 20:12:46 +00:00
Fix various code style issues
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
disabled_rules:
|
||||
- line_length
|
||||
- function_parameter_count
|
||||
- syntactic_sugar
|
||||
- private_over_fileprivate
|
||||
|
||||
opt_in_rules:
|
||||
- empty_count
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ if danger.github?.pullRequest.title.contains("WIP") == true {
|
||||
}
|
||||
|
||||
// Warn when there is a big PR
|
||||
if let additions = danger.github?.pullRequest.additions,
|
||||
if let additions = danger.github?.pullRequest.additions,
|
||||
let deletions = danger.github?.pullRequest.deletions,
|
||||
case let sum = additions + deletions, sum > 1000 {
|
||||
warn("Pull request is relatively big (\(sum) lines changed). If this PR contains multiple changes, consider splitting it into separate PRs for easier reviews.")
|
||||
|
||||
@@ -8,7 +8,7 @@ td {
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#status {
|
||||
|
||||
@@ -18,23 +18,23 @@ import CocoaLumberjackSwift
|
||||
|
||||
final class Formatter: DDDispatchQueueLogFormatter {
|
||||
let threadUnsafeDateFormatter: DateFormatter
|
||||
|
||||
|
||||
override init() {
|
||||
threadUnsafeDateFormatter = DateFormatter()
|
||||
threadUnsafeDateFormatter.formatterBehavior = .behavior10_4
|
||||
threadUnsafeDateFormatter.dateFormat = "HH:mm:ss.SSS"
|
||||
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
||||
override func format(message logMessage: DDLogMessage) -> String {
|
||||
let dateAndTime = threadUnsafeDateFormatter.string(from: logMessage.timestamp)
|
||||
|
||||
|
||||
let logLevel: String
|
||||
let logFlag = logMessage.flag
|
||||
if logFlag.contains(.error) {
|
||||
logLevel = "E"
|
||||
} else if logFlag.contains(.warning){
|
||||
} else if logFlag.contains(.warning) {
|
||||
logLevel = "W"
|
||||
} else if logFlag.contains(.info) {
|
||||
logLevel = "I"
|
||||
@@ -45,7 +45,7 @@ final class Formatter: DDDispatchQueueLogFormatter {
|
||||
} else {
|
||||
logLevel = "?"
|
||||
}
|
||||
|
||||
|
||||
return "\(dateAndTime) |\(logLevel)| [\(logMessage.fileName) \(logMessage.function ?? "nil")] #\(logMessage.line): \(logMessage.message)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,32 +23,27 @@ static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
|
||||
if (@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)) {
|
||||
[DDLog addLogger:[DDOSLogger sharedInstance]];
|
||||
} else {
|
||||
[DDLog addLogger:(DDTTYLogger *)[DDTTYLogger sharedInstance]];
|
||||
}
|
||||
|
||||
|
||||
DDLogVerbose(@"Verbose");
|
||||
DDLogInfo(@"Info");
|
||||
DDLogWarn(@"Warn");
|
||||
DDLogError(@"Error");
|
||||
|
||||
|
||||
DDLog *aDDLogInstance = [DDLog new];
|
||||
if (@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)) {
|
||||
[aDDLogInstance addLogger:[DDOSLogger sharedInstance]];
|
||||
} else {
|
||||
[aDDLogInstance addLogger:(DDTTYLogger *)[DDTTYLogger sharedInstance]];
|
||||
}
|
||||
|
||||
|
||||
DDLogVerboseToDDLog(aDDLogInstance, @"Verbose from aDDLogInstance");
|
||||
DDLogInfoToDDLog(aDDLogInstance, @"Info from aDDLogInstance");
|
||||
DDLogWarnToDDLog(aDDLogInstance, @"Warn from aDDLogInstance");
|
||||
|
||||
@@ -27,12 +27,6 @@ private func printSomething() {
|
||||
}
|
||||
|
||||
final class ViewController: UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
let formatter = Formatter()
|
||||
@@ -45,29 +39,29 @@ final class ViewController: UIViewController {
|
||||
logger.logFormatter = formatter
|
||||
DDLog.add(logger)
|
||||
}
|
||||
|
||||
|
||||
DDLogVerbose("Verbose")
|
||||
DDLogDebug("Debug")
|
||||
DDLogInfo("Info")
|
||||
DDLogWarn("Warn")
|
||||
DDLogError("Error")
|
||||
|
||||
|
||||
printSomething()
|
||||
|
||||
|
||||
dynamicLogLevel = ddloglevel
|
||||
|
||||
|
||||
DDLogVerbose("Verbose")
|
||||
DDLogDebug("Debug")
|
||||
DDLogInfo("Info")
|
||||
DDLogWarn("Warn")
|
||||
DDLogError("Error")
|
||||
|
||||
|
||||
DDLogVerbose("Verbose", level: ddloglevel)
|
||||
DDLogDebug("Debug", level: ddloglevel)
|
||||
DDLogInfo("Info", level: ddloglevel)
|
||||
DDLogWarn("Warn", level: ddloglevel)
|
||||
DDLogError("Error", level: ddloglevel)
|
||||
|
||||
|
||||
printSomething()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,4 @@
|
||||
import WatchKit
|
||||
import Foundation
|
||||
|
||||
final class InterfaceController: WKInterfaceController {
|
||||
|
||||
override func awake(withContext context: Any?) {
|
||||
super.awake(withContext: context)
|
||||
// Configure interface objects here.
|
||||
}
|
||||
|
||||
override func willActivate() {
|
||||
// This method is called when watch view controller is about to be visible to user
|
||||
super.willActivate()
|
||||
}
|
||||
|
||||
override func didDeactivate() {
|
||||
// This method is called when watch view controller is no longer visible
|
||||
super.didDeactivate()
|
||||
}
|
||||
}
|
||||
final class InterfaceController: WKInterfaceController {}
|
||||
|
||||
@@ -17,28 +17,4 @@ import WatchKit
|
||||
import Foundation
|
||||
import UserNotifications
|
||||
|
||||
final class NotificationController: WKUserNotificationInterfaceController {
|
||||
|
||||
override init() {
|
||||
// Initialize variables here.
|
||||
super.init()
|
||||
|
||||
// Configure interface objects here.
|
||||
}
|
||||
|
||||
override func willActivate() {
|
||||
// This method is called when watch view controller is about to be visible to user
|
||||
super.willActivate()
|
||||
}
|
||||
|
||||
override func didDeactivate() {
|
||||
// This method is called when watch view controller is no longer visible
|
||||
super.didDeactivate()
|
||||
}
|
||||
|
||||
override func didReceive(_ notification: UNNotification) {
|
||||
// This method is called when a notification needs to be presented.
|
||||
// Implement it if you use a dynamic notification interface.
|
||||
// Populate your dynamic notification interface as quickly as possible.
|
||||
}
|
||||
}
|
||||
final class NotificationController: WKUserNotificationInterfaceController {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
SCRIPT_NAME="$(basename $0)"
|
||||
SCRIPT_NAME="$(basename "$0")"
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
SCRIPT_NAME="$(basename $0)"
|
||||
SCRIPT_NAME="$(basename "$0")"
|
||||
|
||||
# Arg1: OLD_YEAR
|
||||
# Arg2: NEW_YEAR
|
||||
@@ -71,7 +71,7 @@ if [[ "$(uname -s)" = 'Darwin' ]]; then
|
||||
EXTENDED_REGEX_FLAG_POST_PATH=''
|
||||
fi
|
||||
|
||||
pushd "$(dirname $0)/../" > /dev/null
|
||||
pushd "$(dirname "$0")/../" > /dev/null
|
||||
find ${EXTENDED_REGEX_FLAG_PRE_PATH} \
|
||||
. \
|
||||
${EXTENDED_REGEX_FLAG_POST_PATH} \
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
// to endorse or promote products derived from this software without specific
|
||||
// prior written permission of Deusty, LLC.
|
||||
|
||||
// swiftlint:disable file_length
|
||||
|
||||
@_exported import CocoaLumberjack
|
||||
#if SWIFT_PACKAGE
|
||||
import CocoaLumberjackSwiftSupport
|
||||
@@ -227,24 +229,24 @@ public struct DDLogMessageFormat: ExpressibleByStringInterpolation {
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public mutating func appendInterpolation<Convertible: ReferenceConvertible>(_ c: Convertible) {
|
||||
if c is CVarArg {
|
||||
public mutating func appendInterpolation<Convertible: ReferenceConvertible>(_ convertible: Convertible) {
|
||||
if convertible is CVarArg {
|
||||
print("""
|
||||
[WARNING]: CocoaLumberjackSwift is creating a \(DDLogMessageFormat.self) with an interpolation conforming to `CVarArg` \
|
||||
using the overload for `ReferenceConvertible` interpolations!
|
||||
Please report this as a bug, including the following snippet:
|
||||
```
|
||||
Convertible: \(Convertible.self), ReferenceType: \(Convertible.ReferenceType.self), type(of: c): \(type(of: c))
|
||||
Convertible: \(Convertible.self), ReferenceType: \(Convertible.ReferenceType.self), type(of: convertible): \(type(of: convertible))
|
||||
```
|
||||
""")
|
||||
}
|
||||
// This should be safe, sine the compiler should convert it to the reference.
|
||||
storage.addValue(c as? CVarArg ?? c as! Convertible.ReferenceType, withSpecifier: "%@")
|
||||
storage.addValue(convertible as? CVarArg ?? convertible as! Convertible.ReferenceType, withSpecifier: "%@")
|
||||
}
|
||||
|
||||
@inlinable
|
||||
public mutating func appendInterpolation<Obj: NSObject>(_ o: Obj) {
|
||||
storage.addValue(o, withSpecifier: "%@")
|
||||
public mutating func appendInterpolation<Obj: NSObject>(_ object: Obj) {
|
||||
storage.addValue(object, withSpecifier: "%@")
|
||||
}
|
||||
|
||||
@_disfavoredOverload
|
||||
@@ -610,3 +612,6 @@ public func currentFileName(_ fileName: StaticString = #file) -> String {
|
||||
public func CurrentFileName(_ fileName: StaticString = #file) -> String {
|
||||
currentFileName(fileName)
|
||||
}
|
||||
// swiftlint:enable identifier_name
|
||||
|
||||
// swiftlint:enable file_length
|
||||
|
||||
@@ -26,8 +26,7 @@ final class DDLogCombineTests: XCTestCase {
|
||||
private var subscriptions = Set<AnyCancellable>()
|
||||
|
||||
private var logFormatter: DDLogFileFormatterDefault {
|
||||
//let's return a formatter that doesn't change based where the
|
||||
//test is being run.
|
||||
// let's return a formatter that doesn't change based where the test is being run.
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "yyyy/MM/dd HH:mm:ss:SSS"
|
||||
formatter.calendar = Calendar(identifier: .gregorian)
|
||||
@@ -164,7 +163,7 @@ final class DDLogCombineTests: XCTestCase {
|
||||
XCTAssertEqual(receivedValue, ["2001/01/01 00:01:40:000 An error occurred",
|
||||
"2001/01/01 00:03:20:000 WARNING: this is incorrect"])
|
||||
}
|
||||
|
||||
|
||||
func testQOSNameInstantiation() {
|
||||
let name = "UI"
|
||||
let qos: qos_class_t = {
|
||||
@@ -175,10 +174,9 @@ final class DDLogCombineTests: XCTestCase {
|
||||
return QOS_CLASS_UNSPECIFIED
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
XCTAssertEqual(qos, QOS_CLASS_USER_INTERACTIVE)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -17,14 +17,6 @@ import XCTest
|
||||
@testable import CocoaLumberjackSwift
|
||||
|
||||
final class DDLogMessageFormatTests: XCTestCase {
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testMessageFormatCreationWithNoArgs() {
|
||||
let format: DDLogMessageFormat = "Message with no args"
|
||||
let expectedFormat: String = "Message with no args"
|
||||
|
||||
Reference in New Issue
Block a user