parent
e1cddb710d
commit
7bd8362dae
|
@ -14,7 +14,10 @@
|
|||
|
||||
#### Bug Fixes
|
||||
|
||||
* None.
|
||||
* Fix false positives on `private_subject` rule when using
|
||||
subjects inside functions.
|
||||
[Marcelo Fabri](https://github.com/marcelofabri)
|
||||
[#4643](https://github.com/realm/SwiftLint/issues/4643)
|
||||
|
||||
## 0.50.3: Bundle of Towels
|
||||
|
||||
|
|
|
@ -154,6 +154,10 @@ open class ViolationsSyntaxVisitor: SyntaxVisitor {
|
|||
skippableDeclarations.contains { $0 == FunctionDeclSyntax.self } ? .skipChildren : .visitChildren
|
||||
}
|
||||
|
||||
override open func visit(_ node: SubscriptDeclSyntax) -> SyntaxVisitorContinueKind {
|
||||
skippableDeclarations.contains { $0 == FunctionDeclSyntax.self } ? .skipChildren : .visitChildren
|
||||
}
|
||||
|
||||
override open func visit(_ node: VariableDeclSyntax) -> SyntaxVisitorContinueKind {
|
||||
skippableDeclarations.contains { $0 == VariableDeclSyntax.self } ? .skipChildren : .visitChildren
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@ private extension PrivateSubjectRule {
|
|||
final class Visitor: ViolationsSyntaxVisitor {
|
||||
private let subjectTypes: Set<String> = ["PassthroughSubject", "CurrentValueSubject"]
|
||||
|
||||
override var skippableDeclarations: [DeclSyntaxProtocol.Type] {
|
||||
[FunctionDeclSyntax.self, VariableDeclSyntax.self, SubscriptDeclSyntax.self]
|
||||
}
|
||||
|
||||
override func visitPost(_ node: VariableDeclSyntax) {
|
||||
guard !node.modifiers.isPrivateOrFileprivate,
|
||||
!node.modifiers.containsStaticOrClass else {
|
||||
|
|
|
@ -24,7 +24,7 @@ internal struct PrivateSubjectRuleExamples {
|
|||
Example(
|
||||
#"""
|
||||
final class Foobar {
|
||||
private let goodSubject: PassthroughSubject<Bool, Never> = .ini()
|
||||
private let goodSubject: PassthroughSubject<Bool, Never> = .init()
|
||||
}
|
||||
"""#
|
||||
),
|
||||
|
@ -52,7 +52,7 @@ internal struct PrivateSubjectRuleExamples {
|
|||
Example(
|
||||
#"""
|
||||
final class Foobar {
|
||||
private let goodSubject: CurrentValueSubject<String, Never> = .ini("toto")
|
||||
private let goodSubject: CurrentValueSubject<String, Never> = .init("toto")
|
||||
}
|
||||
"""#
|
||||
),
|
||||
|
@ -89,7 +89,7 @@ internal struct PrivateSubjectRuleExamples {
|
|||
#"""
|
||||
final class Foobar {
|
||||
private let goodSubject:
|
||||
PassthroughSubject<Bool, Never> = .ini()
|
||||
PassthroughSubject<Bool, Never> = .init()
|
||||
}
|
||||
"""#
|
||||
),
|
||||
|
@ -100,6 +100,13 @@ internal struct PrivateSubjectRuleExamples {
|
|||
CurrentValueSubject<Bool, Never>(true)
|
||||
}
|
||||
"""#
|
||||
),
|
||||
Example(
|
||||
"""
|
||||
func foo() {
|
||||
let goodSubject = PassthroughSubject<Bool, Never>(true)
|
||||
}
|
||||
"""
|
||||
)
|
||||
]
|
||||
|
||||
|
@ -135,7 +142,7 @@ internal struct PrivateSubjectRuleExamples {
|
|||
Example(
|
||||
#"""
|
||||
final class Foobar {
|
||||
let goodSubject: PassthroughSubject<Bool, Never> = .ini()
|
||||
let goodSubject: PassthroughSubject<Bool, Never> = .init()
|
||||
}
|
||||
"""#
|
||||
),
|
||||
|
@ -243,7 +250,7 @@ internal struct PrivateSubjectRuleExamples {
|
|||
#"""
|
||||
final class Foobar {
|
||||
let ↓badSubject:
|
||||
PassthroughSubject<Bool, Never> = .ini()
|
||||
PassthroughSubject<Bool, Never> = .init()
|
||||
}
|
||||
"""#
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue