Skip to content

Commit 981ccb0

Browse files
committed
Minor tweaks
1 parent 9e65eac commit 981ccb0

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

.swiftlint.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ only_rules:
2020
- control_statement
2121
- custom_rules
2222
- discarded_notification_center_observer
23+
- discouraged_assert
2324
- discouraged_direct_init
25+
- discouraged_none_name
2426
- discouraged_object_literal
2527
- discouraged_optional_collection
2628
- duplicate_enum_cases
2729
- duplicate_imports
30+
- duplicated_key_in_dictionary_literal
2831
- dynamic_inline
2932
- empty_collection_literal
3033
- empty_count
@@ -80,10 +83,12 @@ only_rules:
8083
- operator_whitespace
8184
- orphaned_doc_comment
8285
- overridden_super_call
86+
- prefer_self_in_static_references
8387
- prefer_self_type_over_type_of_self
8488
- prefer_zero_over_explicit_init
8589
- private_action
8690
- private_outlet
91+
- private_subject
8792
- private_unit_test
8893
- prohibited_super_call
8994
- protocol_property_accessors_order
@@ -99,6 +104,8 @@ only_rules:
99104
- redundant_void_return
100105
- required_enum_case
101106
- return_arrow_whitespace
107+
- return_value_from_void_function
108+
- self_in_property_initialization
102109
- shorthand_operator
103110
- sorted_first_last
104111
- statement_position
@@ -115,6 +122,7 @@ only_rules:
115122
- trailing_newline
116123
- trailing_semicolon
117124
- trailing_whitespace
125+
- unavailable_condition
118126
- unavailable_function
119127
- unneeded_break_in_switch
120128
- unneeded_parentheses_in_closure_argument
@@ -132,12 +140,13 @@ only_rules:
132140
- vertical_whitespace_closing_braces
133141
- vertical_whitespace_opening_braces
134142
- void_return
135-
- weak_delegate
136143
- xct_specific_matcher
137144
- yoda_condition
138145
analyzer_rules:
146+
- capture_variable
139147
- unused_declaration
140148
- unused_import
149+
- typesafe_array_init
141150
number_separator:
142151
minimum_length: 5
143152
identifier_name:
@@ -153,12 +162,14 @@ identifier_name:
153162
excluded:
154163
- 'x'
155164
- 'y'
165+
- 'z'
156166
- 'a'
157167
- 'b'
158168
- 'x1'
159169
- 'x2'
160170
- 'y1'
161171
- 'y2'
172+
- 'z2'
162173
custom_rules:
163174
no_nsrect:
164175
regex: '\bNSRect\b'
@@ -173,8 +184,11 @@ custom_rules:
173184
match_kinds: typeidentifier
174185
message: 'Use CGPoint instead of NSPoint'
175186
swiftui_state_private:
176-
regex: '@(State|StateObject)\s+var'
177-
message: "SwiftUI @State/@StateObject properties should be private"
187+
regex: '@(State|StateObject|ObservedObject|EnvironmentObject)\s+var'
188+
message: 'SwiftUI @State/@StateObject/@ObservedObject/@EnvironmentObject properties should be private'
189+
swiftui_environment_private:
190+
regex: '@Environment\(\\\.\w+\)\s+var'
191+
message: 'SwiftUI @Environment properties should be private'
178192
final_class:
179193
regex: '^class [a-zA-Z\d]+[^{]+\{'
180-
message: "Classes should be marked as final whenever possible. If you actually need it to be subclassable, just add `// swiftlint:disable:next final_class`."
194+
message: 'Classes should be marked as final whenever possible. If you actually need it to be subclassable, just add `// swiftlint:disable:next final_class`.'

Sources/Defaults/Defaults+AnySerializable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extension Defaults.AnySerializable: Hashable {
8888
hasher.combine(value)
8989
case let value as Double:
9090
hasher.combine(value)
91-
case let value as CGFloat: // swiftlint:disable:this no_cgfloat
91+
case let value as CGFloat:
9292
hasher.combine(value)
9393
case let value as String:
9494
hasher.combine(value)

Sources/Defaults/Defaults.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extension Defaults {
8686
}
8787

8888
extension Defaults.Key {
89-
public convenience init<T: Defaults.Serializable>(_ key: String, suite: UserDefaults = .standard) where Value == T? {
89+
public convenience init<T>(_ key: String, suite: UserDefaults = .standard) where Value == T? {
9090
self.init(key, default: nil, suite: suite)
9191
}
9292
}

Sources/Defaults/Utilities.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ final class LifetimeAssociation {
8383
init(of target: AnyObject, with owner: AnyObject, deinitHandler: @escaping () -> Void = {}) {
8484
let wrappedObject = ObjectLifetimeTracker(for: target, deinitHandler: deinitHandler)
8585

86-
let associatedObjects = LifetimeAssociation.associatedObjects[owner] ?? []
87-
LifetimeAssociation.associatedObjects[owner] = associatedObjects + [wrappedObject]
86+
let associatedObjects = Self.associatedObjects[owner] ?? []
87+
Self.associatedObjects[owner] = associatedObjects + [wrappedObject]
8888

8989
self.wrappedObject = wrappedObject
9090
self.owner = owner
@@ -106,14 +106,14 @@ final class LifetimeAssociation {
106106
guard
107107
let owner = owner,
108108
let wrappedObject = wrappedObject,
109-
var associatedObjects = LifetimeAssociation.associatedObjects[owner],
109+
var associatedObjects = Self.associatedObjects[owner],
110110
let wrappedObjectAssociationIndex = associatedObjects.firstIndex(where: { $0 === wrappedObject })
111111
else {
112112
return
113113
}
114114

115115
associatedObjects.remove(at: wrappedObjectAssociationIndex)
116-
LifetimeAssociation.associatedObjects[owner] = associatedObjects
116+
Self.associatedObjects[owner] = associatedObjects
117117
self.owner = nil
118118
}
119119
}

0 commit comments

Comments
 (0)