Skip to content

ineffective-access-modifier

Rubycorrectnessno fixdefault: warnruby/rubocop

Reports private or protected before def self.name, which does not affect it. private_class_method :name in the class makes the method private on purpose and is not reported.

private applies to instance methods only, so the singleton method stays public although it looks private.

To fix, use private_class_method, or open class << self and put the methods after private.

Reported
...
super
end
private
def self.baz; end
...
def qux; end
...
ruby:
lint:
rules:
ineffective-access-modifier: warn # off, warn (default), error

Enabled by the presets: ruby/rubocop.

Suppress one line with sudsy-disable-next-line ineffective-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/IneffectiveAccessModifier full