-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rule Request] Prefer new block based KVO API in Swift 3.2 or 4 #1714
Comments
Probably the most trick thing here is to detect the Swift version. We can the new keypath syntax and the structure to find if it's Swift >= 3.2.
let nameKeyPath = \ForceUser.name
{
"key.offset" : 0,
"key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
"key.length" : 34,
"key.diagnostics" : [
{
"key.filepath" : "\/Users\/marcelofabri\/dev\/SwiftLint\/file.swift",
"key.column" : 19,
"key.description" : "invalid character in source file",
"key.fixits" : [
{
"key.offset" : 18,
"key.sourcetext" : " ",
"key.length" : 1
}
],
"key.line" : 1,
"key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
"key.severity" : "source.diagnostic.severity.error"
}
],
"key.substructure" : [
{
"key.nameoffset" : 4,
"key.accessibility" : "source.lang.swift.accessibility.internal",
"key.length" : 33,
"key.name" : "nameKeyPath",
"key.kind" : "source.lang.swift.decl.var.global",
"key.namelength" : 11,
"key.offset" : 0
}
]
}
{
"key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
"key.substructure" : [
{
"key.nameoffset" : 4,
"key.accessibility" : "source.lang.swift.accessibility.internal",
"key.length" : 33,
"key.name" : "nameKeyPath",
"key.kind" : "source.lang.swift.decl.var.global",
"key.namelength" : 11,
"key.offset" : 0
}
],
"key.offset" : 0,
"key.length" : 34
} Unfortunately, I couldn't find a way do identify whether it's Swift 3.2 or 4. |
Maybe using
|
@ornithocoder Nice! Unfortunately, we still can't tell if it's 3.2 or 4. But I guess in most cases it won't matter anyway. We can leave that for later if needed. |
When using Swift 3.2 or 4, the new block based API KVO API is preferred.
The text was updated successfully, but these errors were encountered: