Skip to content

Rails/ThreeStateBooleanColumn parse exception when table/column is dynamic #1010

Closed
@vlad-pisanov

Description

Currently, Rails/ThreeStateBooleanColumn assumes that the table name and the column name are literals. Passing in a variable or a constant raises a parse exception:

An error occurred while Rails/ThreeStateBooleanColumn cop was inspecting
db/migrate/test.rb:42:6.
undefined method `value' for s(:const, nil, :column):RuboCop::AST::ConstNode

Sample migration:

def up
   table  = :users
   column = :is_admin

   add_column :users, :is_admin, :boolean   # ✔️
   add_column table,  :is_admin, :boolean   # 💥parse exception
   add_column :users,  column,   :boolean   # 💥parse exception
end

(version rubocop-rails-2.19.1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions