From c53f914a77bab5cd5b38bfc40380b8c5acf15121 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 4 Nov 2023 02:03:03 +0900 Subject: [PATCH] Suppress a new RuboCop offense Follow up https://github.com/rubocop/rubocop/pull/12332 This commit suppresses the following new RuboCop offense: ```console $ bundle exec rake (snip) lib/rubocop/cop/rails/save_bang.rb:341:15: C: [Correctable] InternalAffairs/MethodNameEqual: Use !node.method?(:destroy) instead. node.method_name != :destroy && ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 292 files inspected, 1 offense detected, 1 offense autocorrectable ``` --- lib/rubocop/cop/rails/save_bang.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rubocop/cop/rails/save_bang.rb b/lib/rubocop/cop/rails/save_bang.rb index 14a1527d45..133dcc97ee 100644 --- a/lib/rubocop/cop/rails/save_bang.rb +++ b/lib/rubocop/cop/rails/save_bang.rb @@ -336,10 +336,10 @@ def persist_method?(node, methods = RESTRICT_ON_SEND) # Check argument signature as no arguments or one hash def expected_signature?(node) - !node.arguments? || - (node.arguments.one? && - node.method_name != :destroy && - (node.first_argument.hash_type? || !node.first_argument.literal?)) + return true unless node.arguments? + return false if !node.arguments.one? || node.method?(:destroy) + + node.first_argument.hash_type? || !node.first_argument.literal? end end end