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

[rule request] Check for calling super on some overwritten methods #803

Closed
angelolloqui opened this issue Sep 2, 2016 · 1 comment
Closed
Labels
rule-request Requests for a new rules.

Comments

@angelolloqui
Copy link
Contributor

I am not sure if there is a place for this in SwiftLint as this looks pretty custom, but I find myself adding scripts to check wether some super calls are made. Most commonly, UIViewController methods like viewDidLoad, viewWillAppear,... require developers to call super, but they tend to forget, resulting in unpredictable errors. Other classes apart from UIViewController might also apply.

The main issue I see here is that sometimes you actually want to override a method to fully replace it, so it should not apply to all override but just a list of predefined ones. Would you like such a rule to be part of SwiftLint? or since it is based on whitelisting methods then you prefer not? we could also add a configuration provider to list the methods to check (based on name).

I definitely think is a useful rule, but maybe not generic enough for Lint

@jpsim jpsim added the rule-request Requests for a new rules. label Sep 2, 2016
@angelolloqui
Copy link
Contributor Author

BTW, an example of documentation from Apple where it comments that super should be called:

This method is called before the view controller'��s view is about to be added to a view hierarchy and before any animations are configured for showing the view. You can override this method to perform custom tasks associated with displaying the view. For example, you might use this method to change the orientation or style of the status bar to coordinate with the orientation or style of the view being presented. If you override this method, you must call super at some point in your implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule-request Requests for a new rules.
Projects
None yet
Development

No branches or pull requests

3 participants