File tree Expand file tree Collapse file tree
Source/SwiftLintBuiltInRules/Rules/Lint Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments