Minor tweaks
This commit is contained in:
parent
9e65eac602
commit
981ccb0a01
|
@ -20,11 +20,14 @@ only_rules:
|
||||||
- control_statement
|
- control_statement
|
||||||
- custom_rules
|
- custom_rules
|
||||||
- discarded_notification_center_observer
|
- discarded_notification_center_observer
|
||||||
|
- discouraged_assert
|
||||||
- discouraged_direct_init
|
- discouraged_direct_init
|
||||||
|
- discouraged_none_name
|
||||||
- discouraged_object_literal
|
- discouraged_object_literal
|
||||||
- discouraged_optional_collection
|
- discouraged_optional_collection
|
||||||
- duplicate_enum_cases
|
- duplicate_enum_cases
|
||||||
- duplicate_imports
|
- duplicate_imports
|
||||||
|
- duplicated_key_in_dictionary_literal
|
||||||
- dynamic_inline
|
- dynamic_inline
|
||||||
- empty_collection_literal
|
- empty_collection_literal
|
||||||
- empty_count
|
- empty_count
|
||||||
|
@ -80,10 +83,12 @@ only_rules:
|
||||||
- operator_whitespace
|
- operator_whitespace
|
||||||
- orphaned_doc_comment
|
- orphaned_doc_comment
|
||||||
- overridden_super_call
|
- overridden_super_call
|
||||||
|
- prefer_self_in_static_references
|
||||||
- prefer_self_type_over_type_of_self
|
- prefer_self_type_over_type_of_self
|
||||||
- prefer_zero_over_explicit_init
|
- prefer_zero_over_explicit_init
|
||||||
- private_action
|
- private_action
|
||||||
- private_outlet
|
- private_outlet
|
||||||
|
- private_subject
|
||||||
- private_unit_test
|
- private_unit_test
|
||||||
- prohibited_super_call
|
- prohibited_super_call
|
||||||
- protocol_property_accessors_order
|
- protocol_property_accessors_order
|
||||||
|
@ -99,6 +104,8 @@ only_rules:
|
||||||
- redundant_void_return
|
- redundant_void_return
|
||||||
- required_enum_case
|
- required_enum_case
|
||||||
- return_arrow_whitespace
|
- return_arrow_whitespace
|
||||||
|
- return_value_from_void_function
|
||||||
|
- self_in_property_initialization
|
||||||
- shorthand_operator
|
- shorthand_operator
|
||||||
- sorted_first_last
|
- sorted_first_last
|
||||||
- statement_position
|
- statement_position
|
||||||
|
@ -115,6 +122,7 @@ only_rules:
|
||||||
- trailing_newline
|
- trailing_newline
|
||||||
- trailing_semicolon
|
- trailing_semicolon
|
||||||
- trailing_whitespace
|
- trailing_whitespace
|
||||||
|
- unavailable_condition
|
||||||
- unavailable_function
|
- unavailable_function
|
||||||
- unneeded_break_in_switch
|
- unneeded_break_in_switch
|
||||||
- unneeded_parentheses_in_closure_argument
|
- unneeded_parentheses_in_closure_argument
|
||||||
|
@ -132,12 +140,13 @@ only_rules:
|
||||||
- vertical_whitespace_closing_braces
|
- vertical_whitespace_closing_braces
|
||||||
- vertical_whitespace_opening_braces
|
- vertical_whitespace_opening_braces
|
||||||
- void_return
|
- void_return
|
||||||
- weak_delegate
|
|
||||||
- xct_specific_matcher
|
- xct_specific_matcher
|
||||||
- yoda_condition
|
- yoda_condition
|
||||||
analyzer_rules:
|
analyzer_rules:
|
||||||
|
- capture_variable
|
||||||
- unused_declaration
|
- unused_declaration
|
||||||
- unused_import
|
- unused_import
|
||||||
|
- typesafe_array_init
|
||||||
number_separator:
|
number_separator:
|
||||||
minimum_length: 5
|
minimum_length: 5
|
||||||
identifier_name:
|
identifier_name:
|
||||||
|
@ -153,12 +162,14 @@ identifier_name:
|
||||||
excluded:
|
excluded:
|
||||||
- 'x'
|
- 'x'
|
||||||
- 'y'
|
- 'y'
|
||||||
|
- 'z'
|
||||||
- 'a'
|
- 'a'
|
||||||
- 'b'
|
- 'b'
|
||||||
- 'x1'
|
- 'x1'
|
||||||
- 'x2'
|
- 'x2'
|
||||||
- 'y1'
|
- 'y1'
|
||||||
- 'y2'
|
- 'y2'
|
||||||
|
- 'z2'
|
||||||
custom_rules:
|
custom_rules:
|
||||||
no_nsrect:
|
no_nsrect:
|
||||||
regex: '\bNSRect\b'
|
regex: '\bNSRect\b'
|
||||||
|
@ -173,8 +184,11 @@ custom_rules:
|
||||||
match_kinds: typeidentifier
|
match_kinds: typeidentifier
|
||||||
message: 'Use CGPoint instead of NSPoint'
|
message: 'Use CGPoint instead of NSPoint'
|
||||||
swiftui_state_private:
|
swiftui_state_private:
|
||||||
regex: '@(State|StateObject)\s+var'
|
regex: '@(State|StateObject|ObservedObject|EnvironmentObject)\s+var'
|
||||||
message: "SwiftUI @State/@StateObject properties should be private"
|
message: 'SwiftUI @State/@StateObject/@ObservedObject/@EnvironmentObject properties should be private'
|
||||||
|
swiftui_environment_private:
|
||||||
|
regex: '@Environment\(\\\.\w+\)\s+var'
|
||||||
|
message: 'SwiftUI @Environment properties should be private'
|
||||||
final_class:
|
final_class:
|
||||||
regex: '^class [a-zA-Z\d]+[^{]+\{'
|
regex: '^class [a-zA-Z\d]+[^{]+\{'
|
||||||
message: "Classes should be marked as final whenever possible. If you actually need it to be subclassable, just add `// swiftlint:disable:next final_class`."
|
message: 'Classes should be marked as final whenever possible. If you actually need it to be subclassable, just add `// swiftlint:disable:next final_class`.'
|
||||||
|
|
|
@ -88,7 +88,7 @@ extension Defaults.AnySerializable: Hashable {
|
||||||
hasher.combine(value)
|
hasher.combine(value)
|
||||||
case let value as Double:
|
case let value as Double:
|
||||||
hasher.combine(value)
|
hasher.combine(value)
|
||||||
case let value as CGFloat: // swiftlint:disable:this no_cgfloat
|
case let value as CGFloat:
|
||||||
hasher.combine(value)
|
hasher.combine(value)
|
||||||
case let value as String:
|
case let value as String:
|
||||||
hasher.combine(value)
|
hasher.combine(value)
|
||||||
|
|
|
@ -86,7 +86,7 @@ extension Defaults {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Defaults.Key {
|
extension Defaults.Key {
|
||||||
public convenience init<T: Defaults.Serializable>(_ key: String, suite: UserDefaults = .standard) where Value == T? {
|
public convenience init<T>(_ key: String, suite: UserDefaults = .standard) where Value == T? {
|
||||||
self.init(key, default: nil, suite: suite)
|
self.init(key, default: nil, suite: suite)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,8 @@ final class LifetimeAssociation {
|
||||||
init(of target: AnyObject, with owner: AnyObject, deinitHandler: @escaping () -> Void = {}) {
|
init(of target: AnyObject, with owner: AnyObject, deinitHandler: @escaping () -> Void = {}) {
|
||||||
let wrappedObject = ObjectLifetimeTracker(for: target, deinitHandler: deinitHandler)
|
let wrappedObject = ObjectLifetimeTracker(for: target, deinitHandler: deinitHandler)
|
||||||
|
|
||||||
let associatedObjects = LifetimeAssociation.associatedObjects[owner] ?? []
|
let associatedObjects = Self.associatedObjects[owner] ?? []
|
||||||
LifetimeAssociation.associatedObjects[owner] = associatedObjects + [wrappedObject]
|
Self.associatedObjects[owner] = associatedObjects + [wrappedObject]
|
||||||
|
|
||||||
self.wrappedObject = wrappedObject
|
self.wrappedObject = wrappedObject
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
|
@ -106,14 +106,14 @@ final class LifetimeAssociation {
|
||||||
guard
|
guard
|
||||||
let owner = owner,
|
let owner = owner,
|
||||||
let wrappedObject = wrappedObject,
|
let wrappedObject = wrappedObject,
|
||||||
var associatedObjects = LifetimeAssociation.associatedObjects[owner],
|
var associatedObjects = Self.associatedObjects[owner],
|
||||||
let wrappedObjectAssociationIndex = associatedObjects.firstIndex(where: { $0 === wrappedObject })
|
let wrappedObjectAssociationIndex = associatedObjects.firstIndex(where: { $0 === wrappedObject })
|
||||||
else {
|
else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
associatedObjects.remove(at: wrappedObjectAssociationIndex)
|
associatedObjects.remove(at: wrappedObjectAssociationIndex)
|
||||||
LifetimeAssociation.associatedObjects[owner] = associatedObjects
|
Self.associatedObjects[owner] = associatedObjects
|
||||||
self.owner = nil
|
self.owner = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue