Fix lint issues

This commit is contained in:
Sindre Sorhus 2024-01-18 16:58:06 +07:00
parent 2dad0e446e
commit 0f73f9401a
21 changed files with 65 additions and 51 deletions

View File

@ -28,6 +28,7 @@ only_rules:
- discouraged_direct_init
- discouraged_none_name
- discouraged_object_literal
- discouraged_optional_boolean
- discouraged_optional_collection
- duplicate_conditions
- duplicate_enum_cases
@ -79,6 +80,7 @@ only_rules:
- no_extension_access_modifier
- no_fallthrough_only
- no_space_in_method_call
- non_overridable_class_declaration
- notification_center_detachment
- ns_number_init_as_function_reference
- nsobject_prefer_isequal
@ -93,6 +95,7 @@ only_rules:
- private_action
- private_outlet
- private_subject
- private_swiftui_state
- private_unit_test
- prohibited_super_call
- protocol_property_accessors_order
@ -132,6 +135,7 @@ only_rules:
- unavailable_condition
- unavailable_function
- unneeded_break_in_switch
- unneeded_override
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
@ -191,9 +195,16 @@ custom_rules:
regex: '\bNSPoint\b'
match_kinds: typeidentifier
message: 'Use CGPoint instead of NSPoint'
no_cgfloat:
regex: '\bCGFloat\b'
match_kinds: typeidentifier
message: 'Use Double instead of CGFloat'
no_cgfloat2:
regex: '\bCGFloat\('
message: 'Use Double instead of CGFloat'
swiftui_state_private:
regex: '@(State|StateObject|ObservedObject|EnvironmentObject)\s+var'
message: 'SwiftUI @State/@StateObject/@ObservedObject/@EnvironmentObject properties should be private'
regex: '@(ObservedObject|EnvironmentObject)\s+var'
message: 'SwiftUI @ObservedObject/@EnvironmentObject properties should be private'
swiftui_environment_private:
regex: '@Environment\(\\\.\w+\)\s+var'
message: 'SwiftUI @Environment properties should be private'

View File

@ -88,7 +88,7 @@ extension Defaults.AnySerializable: Hashable {
hasher.combine(value)
case let value as Double:
hasher.combine(value)
case let value as CGFloat:
case let value as CGFloat: // swiftlint:disable:this no_cgfloat
hasher.combine(value)
case let value as String:
hasher.combine(value)
@ -135,7 +135,7 @@ extension Defaults.AnySerializable: Equatable {
lhs == rhs
case (let lhs as Double, let rhs as Double):
lhs == rhs
case (let lhs as CGFloat, let rhs as CGFloat):
case (let lhs as CGFloat, let rhs as CGFloat): // swiftlint:disable:this no_cgfloat
lhs == rhs
case (let lhs as String, let rhs as String):
lhs == rhs

View File

@ -412,7 +412,7 @@ extension Defaults {
let object = object as? [Any],
let rawColorspace = object[0] as? String,
let colorspace = CGColorSpace(name: rawColorspace as CFString),
let components = object[1] as? [CGFloat],
let components = object[1] as? [CGFloat], // swiftlint:disable:this no_cgfloat
let cgColor = CGColor(colorSpace: colorspace, components: components)
else {
return nil

View File

@ -41,6 +41,7 @@ extension String: Defaults.Serializable {
public static let isNativelySupportedType = true
}
// swiftlint:disable:next no_cgfloat
extension CGFloat: Defaults.Serializable {
public static let isNativelySupportedType = true
}

View File

@ -6,7 +6,7 @@ extension Defaults {
final class Observable<Value: Serializable>: ObservableObject {
private var cancellable: AnyCancellable?
private var task: Task<Void, Never>?
var key: Defaults.Key<Value> {
didSet {
if key != oldValue {
@ -24,14 +24,14 @@ extension Defaults {
init(_ key: Key<Value>) {
self.key = key
observe()
}
deinit {
task?.cancel()
}
func observe() {
// We only use this on the latest OSes (as of adding this) since the backdeploy library has a lot of bugs.
if #available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) {

View File

@ -169,11 +169,11 @@ final class DefaultsAnySerializableTests: XCTestCase {
XCTAssertEqual(Defaults[any].get()!, URL(string: "https://example.com")!)
#if os(macOS)
// Test NSColor
Defaults[any].set(NSColor(red: CGFloat(103) / CGFloat(0xFF), green: CGFloat(132) / CGFloat(0xFF), blue: CGFloat(255) / CGFloat(0xFF), alpha: 0.987))
Defaults[any].set(NSColor(red: Double(103) / Double(0xFF), green: Double(132) / Double(0xFF), blue: Double(255) / Double(0xFF), alpha: 0.987))
XCTAssertEqual(Defaults[any].get(NSColor.self)?.alphaComponent, 0.987)
#else
// Test UIColor
Defaults[any].set(UIColor(red: CGFloat(103) / CGFloat(0xFF), green: CGFloat(132) / CGFloat(0xFF), blue: CGFloat(255) / CGFloat(0xFF), alpha: 0.654))
Defaults[any].set(UIColor(red: Double(103) / Double(0xFF), green: Double(132) / Double(0xFF), blue: Double(255) / Double(0xFF), alpha: 0.654))
XCTAssertEqual(Defaults[any].get(UIColor.self)?.cgColor.alpha, 0.654)
#endif
// Test Codable type
@ -256,7 +256,7 @@ final class DefaultsAnySerializableTests: XCTestCase {
Defaults[key].insert(float)
XCTAssertTrue(Defaults[key].contains(float))
let cgFloat = Defaults.AnySerializable(CGFloat(12_131.415))
let cgFloat = Defaults.AnySerializable(CGFloat(12_131.415)) // swiftlint:disable:this no_cgfloat2
Defaults[key].insert(cgFloat)
XCTAssertTrue(Defaults[key].contains(cgFloat))
@ -278,7 +278,7 @@ final class DefaultsAnySerializableTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[Defaults.AnySerializable]?>("testArrayOptionalAnyKey")
let key = Defaults.Key<[Defaults.AnySerializable]?>("testArrayOptionalAnyKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [123]
Defaults[key]?.append(456)
@ -315,7 +315,7 @@ final class DefaultsAnySerializableTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: Defaults.AnySerializable]?>("independentDictionaryOptionalAnyKey")
let key = Defaults.Key<[String: Defaults.AnySerializable]?>("independentDictionaryOptionalAnyKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["unicorn": "🦄"]
XCTAssertEqual(Defaults[key]?["unicorn"], "🦄")

View File

@ -28,7 +28,7 @@ final class DefaultsArrayTests: XCTestCase {
}
func testOptionalKey() {
let key = Defaults.Key<[String]?>("independentArrayOptionalStringKey")
let key = Defaults.Key<[String]?>("independentArrayOptionalStringKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = fixtureArray
XCTAssertEqual(Defaults[key]?[0], fixtureArray[0])
@ -108,7 +108,7 @@ final class DefaultsArrayTests: XCTestCase {
}
func testObserveOptionalKeyCombine() {
let key = Defaults.Key<[String]?>("observeArrayOptionalKeyCombine")
let key = Defaults.Key<[String]?>("observeArrayOptionalKeyCombine") // swiftlint:disable:this discouraged_optional_collection
let newName = ["Chen"]
let expect = expectation(description: "Observation closure being called")
@ -157,7 +157,7 @@ final class DefaultsArrayTests: XCTestCase {
}
func testObserveOptionalKey() {
let key = Defaults.Key<[String]?>("observeArrayOptionalKey")
let key = Defaults.Key<[String]?>("observeArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
let expect = expectation(description: "Observation closure being called")
var observation: Defaults.Observation!

View File

@ -53,7 +53,7 @@ final class DefaultsCodableEnumTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[FixtureCodableEnum]?>("independentCodableEnumArrayOptionalKey")
let key = Defaults.Key<[FixtureCodableEnum]?>("independentCodableEnumArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [.halfHour]
}
@ -86,7 +86,7 @@ final class DefaultsCodableEnumTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: FixtureCodableEnum]?>("independentCodableEnumDictionaryOptionalKey")
let key = Defaults.Key<[String: FixtureCodableEnum]?>("independentCodableEnumDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": .tenMinutes]
Defaults[key]?["1"] = .halfHour

View File

@ -74,7 +74,7 @@ final class DefaultsCodableTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[Unicorn]?>("independentCodableArrayOptionalKey")
let key = Defaults.Key<[Unicorn]?>("independentCodableArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [fixtureCodable]
Defaults[key]?.append(Unicorn(isUnicorn: false))
@ -111,7 +111,7 @@ final class DefaultsCodableTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: Unicorn]?>("independentCodableDictionaryOptionalKey")
let key = Defaults.Key<[String: Unicorn]?>("independentCodableDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": fixtureCodable]
Defaults[key]?["1"] = Unicorn(isUnicorn: false)
@ -209,7 +209,7 @@ final class DefaultsCodableTests: XCTestCase {
.map { ($0.oldValue?.isUnicorn, $0.newValue?.isUnicorn) }
.collect(2)
let expectedValue: [(Bool?, Bool?)] = [(nil, true), (true, nil)]
let expectedValue: [(Bool?, Bool?)] = [(nil, true), (true, nil)] // swiftlint:disable:this discouraged_optional_boolean
let cancellable = publisher.sink { tuples in
for (index, expected) in expectedValue.enumerated() {

View File

@ -85,7 +85,7 @@ final class DefaultsCollectionCustomElementTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[Bag<Item>]?>("independentCollectionCustomElementArrayOptionalKey")
let key = Defaults.Key<[Bag<Item>]?>("independentCollectionCustomElementArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
Defaults[key] = [.init(items: [fixtureCustomCollection])]
Defaults[key]?[0].insert(element: fixtureCustomCollection1, at: 1)
Defaults[key]?.append(Bag(items: [fixtureCustomCollection2]))
@ -126,7 +126,7 @@ final class DefaultsCollectionCustomElementTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: Bag<Item>]?>("independentCollectionCustomElementDictionaryOptionalKey")
let key = Defaults.Key<[String: Bag<Item>]?>("independentCollectionCustomElementDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
Defaults[key] = ["0": .init(items: [fixtureCustomCollection])]
Defaults[key]?["0"]?.insert(element: fixtureCustomCollection1, at: 1)
Defaults[key]?["1"] = .init(items: [fixtureCustomCollection2])

View File

@ -81,7 +81,7 @@ final class DefaultsCollectionTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[Bag<String>]?>("independentCollectionArrayOptionalKey")
let key = Defaults.Key<[Bag<String>]?>("independentCollectionArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [Bag(items: [fixtureCollection[0]])]
Defaults[key]?.append(Bag(items: [fixtureCollection[1]]))
@ -118,7 +118,7 @@ final class DefaultsCollectionTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: Bag<String>]?>("independentCollectionDictionaryOptionalKey")
let key = Defaults.Key<[String: Bag<String>]?>("independentCollectionDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": Bag(items: [fixtureCollection[0]])]
Defaults[key]?["0"]?.insert(element: fixtureCollection[1], at: 1)

View File

@ -125,7 +125,7 @@ final class DefaultsCustomBridge: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[User]?>("independentCustomBridgeArrayOptionalKey")
let key = Defaults.Key<[User]?>("independentCustomBridgeArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
let newUser = User(username: "hank121314", password: "123456")
Defaults[key] = [newUser]
@ -174,7 +174,7 @@ final class DefaultsCustomBridge: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: User]?>("independentCustomBridgeDictionaryOptionalKey")
let key = Defaults.Key<[String: User]?>("independentCustomBridgeDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": fixtureCustomBridge]
XCTAssertEqual(Defaults[key]?["0"], fixtureCustomBridge)

View File

@ -30,7 +30,7 @@ final class DefaultsDictionaryTests: XCTestCase {
}
func testOptionalKey() {
let key = Defaults.Key<[String: String]?>("independentDictionaryOptionalKey")
let key = Defaults.Key<[String: String]?>("independentDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = fixtureDictionary
XCTAssertEqual(Defaults[key]?["0"], fixtureDictionary["0"])
@ -100,7 +100,7 @@ final class DefaultsDictionaryTests: XCTestCase {
}
func testObserveOptionalKeyCombine() {
let key = Defaults.Key<[String: String]?>("observeDictionaryOptionalKeyCombine")
let key = Defaults.Key<[String: String]?>("observeDictionaryOptionalKeyCombine") // swiftlint:disable:this discouraged_optional_collection
let expect = expectation(description: "Observation closure being called")
let newName = ["0": "John"]
let publisher = Defaults
@ -148,7 +148,7 @@ final class DefaultsDictionaryTests: XCTestCase {
}
func testObserveOptionalKey() {
let key = Defaults.Key<[String: String]?>("observeDictionaryOptionalKey")
let key = Defaults.Key<[String: String]?>("observeDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
let expect = expectation(description: "Observation closure being called")
var observation: Defaults.Observation!

View File

@ -48,7 +48,7 @@ final class DefaultsEnumTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[FixtureEnum]?>("independentEnumArrayOptionalKey")
let key = Defaults.Key<[FixtureEnum]?>("independentEnumArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [.tenMinutes]
Defaults[key]?.append(.halfHour)
@ -83,7 +83,7 @@ final class DefaultsEnumTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: FixtureEnum]?>("independentEnumDictionaryOptionalKey")
let key = Defaults.Key<[String: FixtureEnum]?>("independentEnumDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": .tenMinutes]
XCTAssertEqual(Defaults[key]?["0"], .tenMinutes)

View File

@ -4,9 +4,9 @@ import Defaults
import XCTest
import AppKit
private let fixtureColor = NSColor(red: CGFloat(103) / CGFloat(0xFF), green: CGFloat(132) / CGFloat(0xFF), blue: CGFloat(255) / CGFloat(0xFF), alpha: 1)
private let fixtureColor1 = NSColor(red: CGFloat(255) / CGFloat(0xFF), green: CGFloat(241) / CGFloat(0xFF), blue: CGFloat(180) / CGFloat(0xFF), alpha: 1)
private let fixtureColor2 = NSColor(red: CGFloat(255) / CGFloat(0xFF), green: CGFloat(180) / CGFloat(0xFF), blue: CGFloat(194) / CGFloat(0xFF), alpha: 1)
private let fixtureColor = NSColor(red: Double(103) / Double(0xFF), green: Double(132) / Double(0xFF), blue: Double(255) / Double(0xFF), alpha: 1)
private let fixtureColor1 = NSColor(red: Double(255) / Double(0xFF), green: Double(241) / Double(0xFF), blue: Double(180) / Double(0xFF), alpha: 1)
private let fixtureColor2 = NSColor(red: Double(255) / Double(0xFF), green: Double(180) / Double(0xFF), blue: Double(194) / Double(0xFF), alpha: 1)
extension Defaults.Keys {
fileprivate static let color = Defaults.Key<NSColor>("NSColor", default: fixtureColor)
@ -57,7 +57,7 @@ final class DefaultsNSColorTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[NSColor]?>("independentNSColorOptionalKey")
let key = Defaults.Key<[NSColor]?>("independentNSColorOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [fixtureColor]
Defaults[key]?.append(fixtureColor1)
@ -91,7 +91,7 @@ final class DefaultsNSColorTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: NSColor]?>("independentNSColorDictionaryOptionalKey")
let key = Defaults.Key<[String: NSColor]?>("independentNSColorDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": fixtureColor]
Defaults[key]?["1"] = fixtureColor1

View File

@ -21,7 +21,7 @@ private final class ExamplePersistentHistory: NSPersistentHistoryToken, Defaults
coder.encode(value, forKey: "value")
}
override class var supportsSecureCoding: Bool { true }
override class var supportsSecureCoding: Bool { true } // swiftlint:disable:this non_overridable_class_declaration
}
// NSSecureCoding
@ -77,7 +77,7 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[ExamplePersistentHistory]?>("independentNSSecureCodingArrayOptionalKey")
let key = Defaults.Key<[ExamplePersistentHistory]?>("independentNSSecureCodingArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [persistentHistoryValue]
XCTAssertEqual(Defaults[key]?[0].value, persistentHistoryValue.value)
@ -120,7 +120,7 @@ final class DefaultsNSSecureCodingTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: ExamplePersistentHistory]?>("independentNSSecureCodingDictionaryOptionalKey")
let key = Defaults.Key<[String: ExamplePersistentHistory]?>("independentNSSecureCodingDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": persistentHistoryValue]
XCTAssertEqual(Defaults[key]?["0"]?.value, persistentHistoryValue.value)

View File

@ -85,7 +85,7 @@ final class DefaultsSetAlgebraCustomElementTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[DefaultsSetAlgebra<Item>]?>("independentSetAlgebraArrayOptionalKey")
let key = Defaults.Key<[DefaultsSetAlgebra<Item>]?>("independentSetAlgebraArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [.init([fixtureSetAlgebra])]
Defaults[key]?[0].insert(fixtureSetAlgebra1)
@ -129,7 +129,7 @@ final class DefaultsSetAlgebraCustomElementTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: DefaultsSetAlgebra<Item>]?>("independentSetAlgebraDictionaryOptionalKey")
let key = Defaults.Key<[String: DefaultsSetAlgebra<Item>]?>("independentSetAlgebraDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": .init([fixtureSetAlgebra])]
Defaults[key]?["0"]?.insert(fixtureSetAlgebra1)

View File

@ -117,7 +117,7 @@ final class DefaultsSetAlgebraTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[DefaultsSetAlgebra<Int>]?>("independentSetAlgebraArrayOptionalKey")
let key = Defaults.Key<[DefaultsSetAlgebra<Int>]?>("independentSetAlgebraArrayOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [.init([fixtureSetAlgebra])]
Defaults[key]?[0].insert(fixtureSetAlgebra1)
@ -161,7 +161,7 @@ final class DefaultsSetAlgebraTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: DefaultsSetAlgebra<Int>]?>("independentSetAlgebraDictionaryOptionalKey")
let key = Defaults.Key<[String: DefaultsSetAlgebra<Int>]?>("independentSetAlgebraDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": .init([fixtureSetAlgebra])]
Defaults[key]?["0"]?.insert(fixtureSetAlgebra1)

View File

@ -27,7 +27,7 @@ final class DefaultsSetTests: XCTestCase {
}
func testOptionalKey() {
let key = Defaults.Key<Set<Int>?>("independentSetOptionalKey")
let key = Defaults.Key<Set<Int>?>("independentSetOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = fixtureSet
XCTAssertEqual(Defaults[key]?.count, fixtureSet.count)

View File

@ -1,3 +1,4 @@
// swiftlint:disable discouraged_optional_boolean
import Foundation
import Combine
import XCTest
@ -818,3 +819,4 @@ extension Task<Never, Never> {
try await sleep(nanoseconds: UInt64(seconds * Double(NSEC_PER_SEC)))
}
}
// swiftlint:enable discouraged_optional_boolean

View File

@ -4,9 +4,9 @@ import Defaults
import XCTest
import UIKit
private let fixtureColor = UIColor(red: CGFloat(103) / CGFloat(0xFF), green: CGFloat(132) / CGFloat(0xFF), blue: CGFloat(255) / CGFloat(0xFF), alpha: 1)
private let fixtureColor1 = UIColor(red: CGFloat(255) / CGFloat(0xFF), green: CGFloat(241) / CGFloat(0xFF), blue: CGFloat(180) / CGFloat(0xFF), alpha: 1)
private let fixtureColor2 = UIColor(red: CGFloat(255) / CGFloat(0xFF), green: CGFloat(180) / CGFloat(0xFF), blue: CGFloat(194) / CGFloat(0xFF), alpha: 1)
private let fixtureColor = UIColor(red: Double(103) / Double(0xFF), green: Double(132) / Double(0xFF), blue: Double(255) / Double(0xFF), alpha: 1)
private let fixtureColor1 = UIColor(red: Double(255) / Double(0xFF), green: Double(241) / Double(0xFF), blue: Double(180) / Double(0xFF), alpha: 1)
private let fixtureColor2 = UIColor(red: Double(255) / Double(0xFF), green: Double(180) / Double(0xFF), blue: Double(194) / Double(0xFF), alpha: 1)
extension Defaults.Keys {
fileprivate static let color = Defaults.Key<UIColor>("NSColor", default: fixtureColor)
@ -56,7 +56,7 @@ final class DefaultsNSColorTests: XCTestCase {
}
func testArrayOptionalKey() {
let key = Defaults.Key<[UIColor]?>("independentNSColorOptionalKey")
let key = Defaults.Key<[UIColor]?>("independentNSColorOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = [fixtureColor]
Defaults[key]?.append(fixtureColor1)
@ -90,7 +90,7 @@ final class DefaultsNSColorTests: XCTestCase {
}
func testDictionaryOptionalKey() {
let key = Defaults.Key<[String: UIColor]?>("independentNSColorDictionaryOptionalKey")
let key = Defaults.Key<[String: UIColor]?>("independentNSColorDictionaryOptionalKey") // swiftlint:disable:this discouraged_optional_collection
XCTAssertNil(Defaults[key])
Defaults[key] = ["0": fixtureColor]
Defaults[key]?["1"] = fixtureColor1