Overridden Method Calls Super

Some overridden methods should always call super.

  • Identifier: overridden_super_call
  • Enabled by default: No
  • Supports autocorrection: No
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning
    excluded []
    included [“*”]

Non Triggering Examples

class VC: UIViewController {
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }
}
class VC: UIViewController {
    override func viewWillAppear(_ animated: Bool) {
        self.method1()
        super.viewWillAppear(animated)
        self.method2()
    }
}
class VC: UIViewController {
    override func loadView() {
    }
}
class Some {
    func viewWillAppear(_ animated: Bool) {
    }
}
class VC: UIViewController {
    override func viewDidLoad() {
    defer {
        super.viewDidLoad()
        }
    }
}

Triggering Examples

class VC: UIViewController {
    override func viewWillAppear(_ animated: Bool) {
        //Not calling to super
        self.method()
    }
}
class VC: UIViewController {
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        //Other code
        super.viewWillAppear(animated)
    }
}
class VC: UIViewController {
    override func didReceiveMemoryWarning() {
    }
}