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

Lint/MissingSuper does not handle dynamically-generated classes #11615

Closed
vlad-pisanov opened this issue Feb 23, 2023 · 0 comments · Fixed by #11619
Closed

Lint/MissingSuper does not handle dynamically-generated classes #11615

vlad-pisanov opened this issue Feb 23, 2023 · 0 comments · Fixed by #11619
Labels

Comments

@vlad-pisanov
Copy link

Currently, Lint/MissingSuper doesn't seem to handle classes generated dynamically via Class.new:

Class.new do
  def initialize; end # no offence ✔️
end

Class.new(String) do
  def initialize; end # no offence ❌(inherited from String -> should call super)
end
class X
  Class.new do
    def initialize; end # no offence ✔️
  end
end

class X < Y
  # X is inherited, but this class isn't -> we shouldn't have to call super
  Class.new do
    def initialize; end # Lint/MissingSuper: Call super to initialize state of the parent class ❌
  end
end
@koic koic added the bug label Feb 24, 2023
koic added a commit to koic/rubocop that referenced this issue Feb 24, 2023
Fixes rubocop#11615.

This commit fixes a false negative for `Lint/MissingSuper`
when no `super` call with `Class.new` block.
koic added a commit to koic/rubocop that referenced this issue Feb 24, 2023
Fixes rubocop#11615.

This commit fixes a false positive for `Lint/MissingSuper`
when using `Class.new` without parent class argument.
bbatsov pushed a commit that referenced this issue Feb 25, 2023
Fixes #11615.

This commit fixes a false negative for `Lint/MissingSuper`
when no `super` call with `Class.new` block.
bbatsov pushed a commit that referenced this issue Feb 25, 2023
Fixes #11615.

This commit fixes a false positive for `Lint/MissingSuper`
when using `Class.new` without parent class argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants