Skip to content

Commit 4a0ca31

Browse files
committed
Updated ShadowingAnyScope to use base function
1 parent 650ba2c commit 4a0ca31

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

Source/SwiftLintBuiltInRules/Rules/Lint/VariableShadowingRule.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private extension VariableShadowingRule {
255255
if !configuration.ignoreParameters {
256256
for param in node.signature.parameterClause.parameters {
257257
let nameToken = param.secondName ?? param.firstName
258-
if nameToken.text != "_", isShadowingAnyScope(nameToken.text) {
258+
if nameToken.text != "_", hasSeenDeclaration(for: nameToken.text) {
259259
violations.append(nameToken.positionAfterSkippingLeadingTrivia)
260260
}
261261
}
@@ -338,7 +338,7 @@ private extension VariableShadowingRule {
338338
private func checkForBindingShadowing(in pattern: PatternSyntax) {
339339
if let identifier = pattern.as(IdentifierPatternSyntax.self) {
340340
let identifierText = identifier.identifier.text
341-
if isShadowingAnyScope(identifierText) {
341+
if hasSeenDeclaration(for: identifierText) {
342342
violations.append(identifier.identifier.positionAfterSkippingLeadingTrivia)
343343
}
344344
} else if let tuple = pattern.as(TuplePatternSyntax.self) {
@@ -358,11 +358,5 @@ private extension VariableShadowingRule {
358358
}
359359
return false
360360
}
361-
362-
/// Checks all scope levels including the current one. Used for parameter checking
363-
/// since parameters are declared into a child scope, not the current one.
364-
private func isShadowingAnyScope(_ identifier: String) -> Bool {
365-
scope.contains { $0.contains { $0.declares(id: identifier) } }
366-
}
367361
}
368362
}

0 commit comments

Comments
 (0)