Skip to content

Commit fd20f61

Browse files
committed
More refactoring
1 parent f7ba528 commit fd20f61

File tree

6 files changed

+74
-57
lines changed

6 files changed

+74
-57
lines changed
File renamed without changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import Foundation
2+
3+
enum LogLevel {
4+
/// No logs
5+
case quiet
6+
/// All logs except `debug`
7+
case `default`
8+
/// All logs
9+
case debug
10+
11+
var shouldLog: Bool {
12+
switch self {
13+
case .quiet:
14+
return false
15+
case .default:
16+
return true
17+
case .debug:
18+
return true
19+
}
20+
}
21+
22+
var shouldDebugLog: Bool {
23+
switch self {
24+
case .quiet:
25+
return false
26+
case .default:
27+
return false
28+
case .debug:
29+
return true
30+
}
31+
}
32+
}
File renamed without changes.

Sources/Helpers/SystemLogger.swift renamed to Sources/Helpers/Logging/SystemLogger.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
//
2-
// Copyright (c) 2024 Adyen N.V.
3-
//
4-
// This file is open source and available under the MIT license. See the LICENSE file for more info.
5-
//
6-
71
import Foundation
82
import OSLog
93

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,18 @@
11
import Foundation
22

3-
fileprivate enum ChangeType {
4-
case change(old: String, new: String)
5-
case removal(String)
6-
case addition(String)
7-
8-
var title: String {
9-
switch self {
10-
case .change: "Changed"
11-
case .removal: "Removed"
12-
case .addition: "Added"
13-
}
14-
}
15-
16-
static func `for`(oldValue: String?, newValue: String?) -> Self? {
17-
if oldValue == newValue { return nil }
18-
if let oldValue, let newValue { return .change(old: oldValue, new: newValue) }
19-
if let oldValue { return .removal(oldValue) }
20-
if let newValue { return .addition(newValue) }
21-
return nil
22-
}
23-
}
24-
253
extension SwiftInterfaceElement {
264

27-
func diffDescription(propertyType: String?, oldValue: String?, newValue: String?) -> [String] {
5+
/// Returns a description for a change between an old and new value
6+
/// - Parameters:
7+
/// - propertyType: The (optional) property type name (e.g. "accessor", "modifier", "generic where clause", ...) for additional information
8+
/// - oldValue: The (optional) old value
9+
/// - newValue: The (optional) new value
10+
/// - Returns: A list with a single item that represents a change description caused by a value change
11+
func diffDescription(
12+
propertyType: String?,
13+
oldValue: String?,
14+
newValue: String?
15+
) -> [String] {
2816

2917
guard let changeType: ChangeType = .for(oldValue: oldValue, newValue: newValue) else { return [] }
3018

@@ -47,6 +35,12 @@ extension SwiftInterfaceElement {
4735
return [diffDescription]
4836
}
4937

38+
/// Returns a list of change descriptions for changes between the old and new values
39+
/// - Parameters:
40+
/// - propertyType: The (optional) property type name (e.g. "accessor", "modifier", "generic where clause", ...) for additional information
41+
/// - oldValue: The (optional) old values
42+
/// - newValue: The (optional) new values
43+
/// - Returns: A list of change descriptions caused by a value change
5044
func diffDescription(propertyType: String, oldValues: [String]?, newValues: [String]?) -> [String] {
5145

5246
if let oldValues, let newValues {
@@ -68,3 +62,28 @@ extension SwiftInterfaceElement {
6862
return []
6963
}
7064
}
65+
66+
// MARK: -
67+
68+
/// File-private helper to produce detailed descriptions
69+
fileprivate enum ChangeType {
70+
case change(old: String, new: String)
71+
case removal(String)
72+
case addition(String)
73+
74+
var title: String {
75+
switch self {
76+
case .change: "Changed"
77+
case .removal: "Removed"
78+
case .addition: "Added"
79+
}
80+
}
81+
82+
static func `for`(oldValue: String?, newValue: String?) -> Self? {
83+
if oldValue == newValue { return nil }
84+
if let oldValue, let newValue { return .change(old: oldValue, new: newValue) }
85+
if let oldValue { return .removal(oldValue) }
86+
if let newValue { return .addition(newValue) }
87+
return nil
88+
}
89+
}

Sources/Pipeline/Pipeline+Protocols.swift

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,6 @@ protocol ProjectAnalyzing {
5555
) throws -> ProjectAnalyzerResult
5656
}
5757

58-
enum LogLevel {
59-
case quiet
60-
case `default`
61-
case debug
62-
63-
var shouldLog: Bool {
64-
switch self {
65-
case .quiet:
66-
return false
67-
case .default:
68-
return true
69-
case .debug:
70-
return true
71-
}
72-
}
73-
74-
var shouldDebugLog: Bool {
75-
switch self {
76-
case .quiet:
77-
return false
78-
case .default:
79-
return false
80-
case .debug:
81-
return true
82-
}
83-
}
84-
}
85-
8658
protocol Logging {
8759

8860
func log(_ message: String, from subsystem: String)

0 commit comments

Comments
 (0)