Skip to content

type_contents_order false positive with willMove(toParent:) #3478

Description

@kacper1703

New Issue Checklist

Describe the bug

For a following code in a UIViewController:

override func viewDidDisappear(_ animated: Bool) {
    super.viewDidDisappear(animated)
    viewModel.viewDidDisappear()
}

override func willMove(toParent parent: UIViewController?) { 
    super.willMove(toParent: parent)
    if parent == nil { //detect "Back" tapping
        viewModel.willMoveToParent()
    }
}

override func viewDidLoad() {
    super.viewDidLoad()
    configureUI(with: viewModel)
}

the type_contents_order is triggered in willMove(toParent:). This is a lifecycle method, so the rule should not be triggered.

Environment

  • SwiftLint version 0.42.0
  • Installation method used - CocoaPods
  • Xcode 12.2 (12B45b)
  • Configuration file:
opt_in_rules:
- type_contents_order

type_contents_order:
    excluded: ".*Tests\\.swift"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected and reproducible misbehavior.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions