Skip to content

Commit 9020b77

Browse files
authored
Merge pull request #899 from koic/fix_a_false_positive_for_rails_active_record_aliases
[Fix #898] Fix a false positive for `Rails/ActiveRecordAliases`
2 parents e0beae0 + 9d7afad commit 9020b77

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#898](https://github.com/rubocop/rubocop-rails/issues/898): Fix a false positive for `Rails/ActiveRecordAliases` when arguments of `update_attributes` is empty. ([@koic][])

lib/rubocop/cop/rails/active_record_aliases.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class ActiveRecordAliases < Base
2626
RESTRICT_ON_SEND = ALIASES.keys.freeze
2727

2828
def on_send(node)
29+
return if node.arguments.empty?
30+
2931
method_name = node.method_name
3032
alias_method = ALIASES[method_name]
3133

spec/rubocop/cop/rails/active_record_aliases_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
RUBY
2626
end
2727
end
28+
29+
context 'when arguments of `update_attributes` is empty' do
30+
it 'does not register an offense' do
31+
expect_no_offenses(<<~RUBY)
32+
user.update(update_attributes)
33+
RUBY
34+
end
35+
end
2836
end
2937

3038
describe '#update_attributes!' do

0 commit comments

Comments
 (0)