The rails dynamic find_by cop should not flag code if the TargetRailsVersion is < ? (I can't find when this functionality changed).
The dynamic find_by cop doesn't observe the TargetRailsVersion and flags these issues and even autocorrects them replacing them with invalid code. I realize that I can disable the cop but it makes more sense for TargetRailsVersion to work properly for this cop.
rails version 3.2.16 create a model and use a find_by_attribute call
0.51.0 (using Parser 2.3.3.1, running on ruby 2.1.0 x86_64-linux)
https://github.com/bbatsov/rubocop/pull/4980#issuecomment-341291779
RuboCop does not support Rails 3.
BTW, we can add a documentation for supported Rails versions probably.
I think we will keep getting this issue for as long as folks run Rubocop on Rails 3 apps. (a.k.a. forever)
Ideally, the Rails cops would be extracted to another gem that depends on Rails 4+. Until then, maybe we should disable all the Rails cops if Rails <4 is detected?
I'm not convinced any documentation is going to prevent folks from being confused/upset initially. They might find the documentation after seeing the offense on their Rails 3 app and not open another issue, but it would be better if we got out ahead of this somehow.
Adding this to the readme would be great for me especially since none of the other Rails cops have given me any trouble. We're running a supported version of ruby and there was no indication that Rails 3 would not be supported. We're also looking to upgrade to rails 4 later this year and I'm particularly motivated because of this issue.
Thanks for the response!
Most helpful comment
I think we will keep getting this issue for as long as folks run Rubocop on Rails 3 apps. (a.k.a. forever)
Ideally, the Rails cops would be extracted to another gem that depends on Rails 4+. Until then, maybe we should disable all the Rails cops if Rails <4 is detected?
I'm not convinced any documentation is going to prevent folks from being confused/upset initially. They might find the documentation after seeing the offense on their Rails 3 app and not open another issue, but it would be better if we got out ahead of this somehow.