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

Force Unwrapping rule doesn't apply to self #2759

Closed
skagedal opened this issue May 15, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@skagedal
Copy link

commented May 15, 2019

New Issue Checklist

Describe the bug

Linting the following snippet with force_unwrapping enabled in .swiftlint.yml:

class Test {
    func foo() {
        DispatchQueue.main.async { [weak self] in
            var string: String?
            _ = string!
            _ = self!
        }
    }
}

I would expect SwiftLint to warn on both force unwrappings. However, it does not catch self!.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint        
Loading configuration from '.swiftlint.yml'
Linting Swift files at paths 
Linting 'foo.swift' (1/1)
/Users/simon/tmp/testswiftlint/foo.swift:5:23: warning: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

0.32.0 - installed with Homebrew

opt_in_rules:
  - force_unwrapping

Running Xcode 10.2.1 (confirmed with xcode-select -p), not using nested configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.