Cop Rails/ActiveRecordAliases: does its job very well and I like it. Though if update_attributes is called from non ActiveRerord object, then autocorrect will break the code. For example, we call update_attributes from sobject.rb of databasedotcom gem
Is there any way to avoid this, except using rubocop:disable?
Rails/ActiveRecordAliases replaces update_attributes calls with update only for activerecord/model objects
Rails/ActiveRecordAliases replaces all the update_attributes calls with update
Unfortunately, there isn't a good way to detect if it is a non ActiveRecord object. RuboCop relies on static code analysis so we can only tell what is statically in a file. In the case of Rails/ActiveRecordAliases, the cop is looking for any code that calls update_attributes. Since databasedotcom implements its own update_attributes method, this will always result in a false positive. If databasedotcom is limited in its usage, you could disable the Rails/ActiveRecordAliases cop for those files or directories.
On a side note, it looks like databasedotcom is deprecated in favor of restforce. restforce does not appear to implement an update_attributes method.
Unfortunately, Rubocop is a static analysis tool and can't know the class of the object receiving update_attributes.
Sometimes there's a bit of context around that Rubocop can take into account for these kinds of things. If you can think of something, please let us know. Otherwise I think you'll need to resort to disabling the cop on each false report, for a subdirectory of your app, or for the whole project.
Oops. I should have refreshed the page to see @rrosenblum's comment before posting mine.
Most helpful comment
Unfortunately, Rubocop is a static analysis tool and can't know the class of the object receiving
update_attributes.Sometimes there's a bit of context around that Rubocop can take into account for these kinds of things. If you can think of something, please let us know. Otherwise I think you'll need to resort to disabling the cop on each false report, for a subdirectory of your app, or for the whole project.
Oops. I should have refreshed the page to see @rrosenblum's comment before posting mine.