Closed
Description
I had a possible false positive for this rule when I used a local method named update_attributes.
Expected behavior
def update_attributes(raw_attributes)
{
name: raw_attributes['nome'],
date_of_birth: Date.parse(raw_attributes['dataDeNascimento']),
document_number: raw_attributes['NumeroDoDocumento']
}
end
user = User.find(1)
user.update(update_attributes)
No issue was pointed out.
Actual behavior
def update_attributes(raw_attributes)
{
name: raw_attributes['nome'],
date_of_birth: Date.parse(raw_attributes['dataDeNascimento']),
document_number: raw_attributes['NumeroDoDocumento']
}
end
user = User.find(1)
user.update(update_attributes)
W: [Correctable] Rails/ActiveRecordAliases: Use update instead of update_attributes.
Steps to reproduce the problem
- put the above code in a file, for example,
app/models/user_test.rb
; - Run cops:
bundle exec rubocop app/models/user_test.rb
RuboCop version
1.35.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.0.3 x86_64-linux-musl)
- rubocop-performance 1.15.0
- rubocop-rails 2.16.1
- rubocop-rspec 2.13.2
Activity