mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
Move XCTestHelpers to TestCaseAccessibilityRule.swift (#4552)
it's only used in that file
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
import SwiftSyntax
|
||||
|
||||
enum XCTestHelpers {
|
||||
private static let testVariableNames: Set = [
|
||||
"allTests"
|
||||
]
|
||||
|
||||
static func isXCTestFunction(_ function: FunctionDeclSyntax) -> Bool {
|
||||
guard !function.modifiers.containsOverride else {
|
||||
return true
|
||||
}
|
||||
|
||||
return !function.modifiers.containsStaticOrClass &&
|
||||
function.identifier.text.hasPrefix("test") &&
|
||||
function.signature.input.parameterList.isEmpty
|
||||
}
|
||||
|
||||
static func isXCTestVariable(_ variable: VariableDeclSyntax) -> Bool {
|
||||
guard !variable.modifiers.containsOverride else {
|
||||
return true
|
||||
}
|
||||
|
||||
return
|
||||
variable.modifiers.containsStaticOrClass &&
|
||||
variable.bindings
|
||||
.compactMap { $0.pattern.as(IdentifierPatternSyntax.self)?.identifier.text }
|
||||
.allSatisfy(testVariableNames.contains)
|
||||
}
|
||||
}
|
||||
@@ -143,3 +143,31 @@ private extension ClassDeclSyntax {
|
||||
} ?? []
|
||||
}
|
||||
}
|
||||
|
||||
private enum XCTestHelpers {
|
||||
private static let testVariableNames: Set = [
|
||||
"allTests"
|
||||
]
|
||||
|
||||
static func isXCTestFunction(_ function: FunctionDeclSyntax) -> Bool {
|
||||
guard !function.modifiers.containsOverride else {
|
||||
return true
|
||||
}
|
||||
|
||||
return !function.modifiers.containsStaticOrClass &&
|
||||
function.identifier.text.hasPrefix("test") &&
|
||||
function.signature.input.parameterList.isEmpty
|
||||
}
|
||||
|
||||
static func isXCTestVariable(_ variable: VariableDeclSyntax) -> Bool {
|
||||
guard !variable.modifiers.containsOverride else {
|
||||
return true
|
||||
}
|
||||
|
||||
return
|
||||
variable.modifiers.containsStaticOrClass &&
|
||||
variable.bindings
|
||||
.compactMap { $0.pattern.as(IdentifierPatternSyntax.self)?.identifier.text }
|
||||
.allSatisfy(testVariableNames.contains)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user