-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Rails/UniqueValidationWithoutIndex: False positive when there's no t.index #221
Comments
Same issue here using |
Thank you for the feedback. AFAIK, the expression of index written in db/schema.rb changes between Rails 4 and Rails 5. And The Rails core team currently maintains versions Rails 6.0.Z and 5.2.Z. Therefore, RuboCop Rails will drop support for Rails 4 in near future (Maybe 5.0 and 5.1 will be supported for a while). So, I will consider whether to implement the feature whose support will be cut in near future. |
…`add_index` Fixes rubocop#221. This PR makes `Rails/UniqueValidationWithoutIndex` aware of `add_index` in db/schema.rb. Rails 4.0 and Rails 4.1 support will drop shortly, but Rails 4.2 may be a bit ahead. There may be changes to these support after the bug fix release of RoboCop Rails 2.5 series.
This issue resolved by #222 because Rails 4.0 and Rails 4.1 support will drop shortly, but Rails 4.2 may be a bit ahead. Thank you. |
…`add_index` Fixes rubocop#221. This PR makes `Rails/UniqueValidationWithoutIndex` aware of `add_index` in db/schema.rb. Rails 4.0 and Rails 4.1 support will drop shortly, but Rails 4.2 may be a bit ahead. There may be changes to these support after the bug fix release of RoboCop Rails 2.5 series.
…`add_index` Fixes rubocop#221. This PR makes `Rails/UniqueValidationWithoutIndex` aware of `add_index` in db/schema.rb. Rails 4.0 and Rails 4.1 support will drop shortly, but Rails 4.2 may be a bit ahead. There may be changes to these support after the bug fix release of RoboCop Rails 2.5 series.
…`add_index` Fixes rubocop#221. This PR makes `Rails/UniqueValidationWithoutIndex` aware of `add_index` in db/schema.rb. Rails 4.0 and Rails 4.1 support will drop shortly, but Rails 4.2 may be a bit ahead. There may be changes to these support after the bug fix release of RoboCop Rails 2.5 series.
…x_aware_of_add_index [Fix #221] Make `Rails/UniqueValidationWithoutIndex` aware of `add_index`
I just ran into the same issue using the t.string :key, null: false, index: true Not sure if it is because of old versions, could be the cause. I just cannot update them 🥲 versions:
|
Have the same problem with: |
I don't really know what is the problem, but I saw the spec of this cop and found no example that uses
add_index
rather thant.index
on schema.rb, so I guess that could be the reason.I tried the rubocop-rails in the versions 2.4 and 2.5
Expected behavior
No errors raised
Actual behavior
Output:
My schema.rb related to the model:
Steps to reproduce the problem
Having a
add_index
instead of at.index
onschema.rb
, I guess.RuboCop version
The text was updated successfully, but these errors were encountered: