Skip to content

New cop: Dangerous name for column and enum #158

Closed
@pocke

Description

@pocke

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

Some keywords, which is allowed by AR, conflict Rails features.
The most popular example is "type". It conflicts with STI.

And we can find other examples.

class C < ApplicationRecord
  enum x: {
    :present, # It breaks C#present?
    :none,
}
end

Describe the solution you'd like

Detect the dangerous names by RuboCop.

Describe alternatives you've considered

In the enum case, we can use _prefix: true option instead.
So the cop should be aware of the option.

Additional context

I think we need more examples for the cop. If you have any idea, please comment to this issue!

I was inspired by ruby-jp members. Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions