Skip to content

useless-access-modifier

Rubysuspiciousno fixdefault: warnruby/rubocop

Reports a bare private, protected, public or module_function that repeats the visibility already in force, or is followed by no method definition.

The modifier does nothing, so a reader who relies on it believes methods are private that are not, or the other way round.

To fix, delete it, or move the methods it was meant to cover under it.

Reported
...
end
private
...
private
def qux; end
public
end
class C
...
super
end
private
end
class D < B
...
ruby:
lint:
rules:
useless-access-modifier: warn # off, warn (default), error

Enabled by the presets: ruby/rubocop.

Suppress one line with sudsy-disable-next-line useless-access-modifier 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/UselessAccessModifier full