Skip to content

[Feature]: detect lifecycle methods not calling super #376

Description

@Janneman84

Problem to solve

I'm the creator of LeakedViewControllerDetector (which is incorporated in DebugSwift). In order for the detector to work super.viewDidLoad() must be called every time it's overridden. However this is easy to overlook, since it doesn't really have any other consequences if you don't.

Proposed solution

I'm thinking of a way to detect missing super calls in these lifecycle methods, at least some of them, without having to rely on linters. For example, using method swizzling on all lifecycle methods I could detect all methods called that either call super or are not overridden in the first place. If you detect viewWillAppear() but have not detected viewDidLoad() you know the latter does not call super (and the leak detector won't work).

If you override all lifecycle methods and don't call super in any of them this still won't work of course, but that would be unlikely.

Anyway this is what I'm thinking at the moment and I wonder if you guys have any thoughts on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions