Skip to content

useless-method-definition

Rubysuspiciousno fixdefault: offruby/rubocop

Reports a method whose whole body is a bare super.

The method does what the inherited one does, so the definition adds only code.

To fix, delete the method.

Reported
...
class B < StandardError
def initialize(msg)
super(msg)
end
def foo=(_v)
...
end
class C
def run
super
end
...
ruby:
lint:
rules:
useless-method-definition: warn # off (default), warn, error

Enabled by the presets: ruby/rubocop.

Suppress one line with sudsy-disable-next-line useless-method-definition in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
rubocop Lint/UselessMethodDefinition full