Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redundant_optional_initialization rule does not provide violations for ones inside the functions. #2233

Closed
VivoEx opened this issue Jun 7, 2018 · 1 comment
Labels
bug Unexpected and reproducible misbehavior.

Comments

@VivoEx
Copy link

VivoEx commented Jun 7, 2018

We do not see violations with redundant_optional_initialization rule for the vars inside the fuctions neither does it get autocorrected whereas works ok over the class variables.

class ClassName {
   ....
    var optionalVar: String? // This line provides violation and thus corrected during autocorrect
   
    func funcName() {
        var optionalVar: String? // This doesn't provide violation
        ....
    }

}

Swiftlint 0.25.1
Swift 4.1

@marcelofabri
Copy link
Collaborator

The problem here is that SourceKit doesn't return key.setter_accessibility for local variables. We use that to know if it's a var or a let, because if it's a let, we shouldn't warn.

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Jun 7, 2018
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Aug 14, 2018
sjavora pushed a commit to sjavora/SwiftLint that referenced this issue Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

No branches or pull requests

2 participants