Skip to content

unused_capture_list false positive with explicit capturing of unowned self in Swift 5.3 #3389

Closed

Description

@lordzsolt

New Issue Checklist

Describe the bug

Same issue as #3267 but with unowned instead of strong.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint Example.swift --no-cache                   
Linting Swift files at paths Example.swift
Linting 'Example.swift' (1/1)
Example.swift:14:50: warning: Unused Capture List Violation: Unused reference self in a capture list should be removed. (unused_capture_list)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.40.3

  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Cocoapods

  • Paste your configuration file: none, unused_capture_list is enabled by default

  • Are you using nested configurations? No

  • Which Xcode version are you using (check xcodebuild -version)? Xcode 12.2 Beta

  • Do you have a sample that shows the issue?

override func viewDidLoad() {
	super.viewDidLoad() {
		rx.onViewDidAppear.subscribe(onNext: { [unowned self] in 
			doSomething()
		}).disposed(by: disposeBag)
	}

	func doSomething() {
		print("Watch this")
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions