Skip to content

Allow instance variables inside class definition in helpers #1525

@javierav

Description

@javierav

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

Imagine the following helper:

module ButtonHelper
  class Button
    def initialize(text:)
      @text = text
    end
  end

  def button(**)
    render Button.new(**)
  end
end

Currently rubocop returns the offense Rails/HelperInstanceVariable: Do not use instance variables in helpers.

Describe the solution you'd like

Rubocop should analyze whether the use of the instance variable occurs within a class, in which case it should ignore it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions