Use `is` instead of `as` for simple type checks
This commit is contained in:
parent
a2facce70c
commit
cf1e2e27dc
|
@ -305,12 +305,12 @@ private class Visitor: ViolationsSyntaxVisitor {
|
||||||
|
|
||||||
override func visitPost(_ node: IdentifierExprSyntax) {
|
override func visitPost(_ node: IdentifierExprSyntax) {
|
||||||
guard let parent = node.parent,
|
guard let parent = node.parent,
|
||||||
parent.as(SpecializeExprSyntax.self) == nil,
|
!parent.is(SpecializeExprSyntax.self),
|
||||||
parent.as(DictionaryElementSyntax.self) == nil,
|
!parent.is(DictionaryElementSyntax.self),
|
||||||
parent.as(ArrayElementSyntax.self) == nil else {
|
!parent.is(ArrayElementSyntax.self) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if parent.as(FunctionCallExprSyntax.self) != nil, case .likeClass(_, false) = parentDeclScopes.last {
|
if parent.is(FunctionCallExprSyntax.self), case .likeClass(_, false) = parentDeclScopes.last {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
addViolation(on: node.identifier)
|
addViolation(on: node.identifier)
|
||||||
|
@ -362,7 +362,7 @@ private class Visitor: ViolationsSyntaxVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func visitPost(_ node: SimpleTypeIdentifierSyntax) {
|
override func visitPost(_ node: SimpleTypeIdentifierSyntax) {
|
||||||
if node.parent?.as(KeyPathExprSyntax.self) != nil {
|
if node.parent?.is(KeyPathExprSyntax.self) == true {
|
||||||
addViolation(on: node.name)
|
addViolation(on: node.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue