-
Couldn't load subscription status.
- Fork 2.3k
Open
Labels
rule-requestRequests for a new rules.Requests for a new rules.
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
Feature or Enhancement Proposal
Variable shadowing is an anti-pattern because it makes code harder to understand. It is a compiler error in many languages. I think it would be great to warn against it in SwiftLint. Here is an example:
var b: String? = "thank"
test(a:"you")
func test(a: String?) {
if let b = a {
print("b:\(b)")
let b = "wow"
print("b:\(b)")
}
}
- The line
if let b = a {shadows the above variable b - The line
let b = "wow"redeclares b as a new variable
In my opinion both of these should be covered by SwiftLint.

aidan-waite, SimplyDanny and grahamburgsmaaidan-waite and crayolakat
Metadata
Metadata
Assignees
Labels
rule-requestRequests for a new rules.Requests for a new rules.