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

Add new rule: Methods should not be empty #9

Open
fabriciocolombo opened this issue Oct 9, 2015 · 3 comments
Open

Add new rule: Methods should not be empty #9

fabriciocolombo opened this issue Oct 9, 2015 · 3 comments

Comments

@fabriciocolombo
Copy link
Owner

There are several reasons for a method not to have a method body:

  • It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
  • It is not yet, or never will be, supported. In this case an [ENotImplemented|ENotSupportedException] should be raised.
  • The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.

Exception
An abstract class' may have empty methods, in order to provide default implementations for child classes.

@fabriciocolombo fabriciocolombo added this to the 0.3.3 milestone Oct 9, 2015
@Teloah
Copy link
Contributor

Teloah commented Dec 17, 2015

Isn't this already kind of covered by "Empty 'begin' statement" rule? I see a lot of those violations, because I quite heavily use Null Object Pattern and, naturally, have a lot of empty methods.

@fabriciocolombo
Copy link
Owner Author

In a way yes, but empty 'begin' statement is very generic.
Methods should not be empty is more specific.
We'll leave this on hold for now.

@fabriciocolombo fabriciocolombo removed this from the 0.3.3 milestone Dec 18, 2015
@marcosrocha85
Copy link

On a past team I worked, we used to just write an "Exit;" statement on virtual procedures that weren't abstract. Just because on Delphi 5 if you override an abstract method and call inherited, the IDE raises an abstract error. Above Delphi 6 that error doesn't appear anymore. So I think that situation should be considered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants