Skip to content

Cop request: private delegates #368

@Drenmi

Description

@Drenmi

Is your feature request related to a problem? Please describe.

When using #delegate, ActiveSupport creates a new method on the class, but this method does not respect the visibility scope of said class.

For example:

class Foo def initialize(bar) @bar = bar end attr_reader :bar private delegate :baz, to: :bar end

The generated method #baz will not be private. The #delegate method does, however, provide an option to create a private method like so:

delegate :baz, to: :bar, private: true

Describe the solution you'd like

I would like a cop that detects calls to #delegate that:

  1. Are in a private scope.
  2. Does not pass the private: true option.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions