There are cases where I'm explicitly avoiding calling super in an initializer, however this cop complains on all of them. This doesn't seem very useful.
There's also a request to have a list of accepted superclasse exceptions, would that resolve the issue for you?
I'm curious of examples where there are good reasons to explicitly not call super.
I'm curious of examples where there are good reasons to explicitly not call super.
馃憤
There's also a request to have a list of accepted superclasse exceptions, would that resolve the issue for you?
Not really. I just don't think this should be a rubocop.
I'm curious of examples where there are good reasons to explicitly not call super.
One concern would be for performance (though this is not a primary concern). Another is that this makes the code harder to read as I might have to navigate to another file to see what logic is happening there (and this could be hard to find if it's in a gem). Mostly I'm concerned that this is not idiomatic for libraries like view_component (https://github.com/github/view_component#implementation) If a new coder sees super calls they may wonder why the last developer didn't use the patterns promoted by the library authors.
I might have to navigate to another file to see what logic is happening there
The idea is that if there was no initialize method, say, would you actually go to another file to see what the inherited initialize does?
That said, if others feel this Cop should be disabled by default, I won't stand in the way.
Sorbet is one counter-example where you don't want to call super necessarily, born out of @will's post on standard https://github.com/testdouble/standard/issues/195
It'd be really awesome if this was configurable for which callbacks, because I think there are fewer cases where you'd _intentionally_ skip calling super on method_missing than on initialize. Any chance of that?
Speaking of those two cases (notice no parent class):
class Foo
def method_missing(*args)
super
```ruby
class Foo
def self.inherited(base)
super
Is `super` really necessary? Why?
@fatkodima can you please provide an example of what will break for a missing `super` with no parent class?
PS Also here
```ruby
module M
def self.included(base)
super
Yes, without parent classes those are not really strictly necessary.
For the example with M module, that was fixed on master, if I remember correctly.
Not necessary, but can't hurt.
I also don't think we are dealing with:
class Foo
extend ModDependingOnInheritedCallback
def self.inherited(base)
super
or
# base.rb
class Foo < Bar
# ...
# extension.rb
class Foo
def self.inherited
Here's an example of method_missing not calling super but perfectly working. https://github.com/faker-ruby/faker/blob/9ea5a3d/lib/helpers/unique_generator.rb#L17-L27
Falling back to raise instead of super seems like a possible scenario for a method_missing (but I'm not sure if we should allow this here in this cop).