-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New cop: Dangerous name for column and enum #158
Comments
Rails has detecting conflict feature, but I cannot get any errors with enum and |
I have another case. With Rails 6 enum now autogenerates negated scopes for each enum value as well and it becomes dangerous to have enum values starting with Consider a case like this:
It does throw a warning but warnings often get swallowed by CI environments. |
FYI. The next Rails version (7.1?) may cause runtime errors when using some dangerous methods from Object: |
[Fix #158] Add `Rails/DangerousColumnNames` cop
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.
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!
The text was updated successfully, but these errors were encountered: