From 7cd8e41fc3d9f78f25c52259ae0b9b7052bb009e Mon Sep 17 00:00:00 2001 From: ydah Date: Thu, 2 Oct 2025 21:51:22 +0900 Subject: [PATCH] Refactor style_offense? method to simplify offense checks for variable types follow up: https://github.com/rubocop/rubocop-rspec/pull/2114/files#r2398699122 --- lib/rubocop/cop/rspec/variable_definition.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/rubocop/cop/rspec/variable_definition.rb b/lib/rubocop/cop/rspec/variable_definition.rb index 4bfe1509b..8a166bea0 100644 --- a/lib/rubocop/cop/rspec/variable_definition.rb +++ b/lib/rubocop/cop/rspec/variable_definition.rb @@ -60,16 +60,8 @@ def correct_variable(variable) end def style_offense?(variable) - (style == :symbols && string?(variable)) || - (style == :strings && symbol?(variable)) - end - - def string?(node) - node.str_type? - end - - def symbol?(node) - node.any_sym_type? + (style == :symbols && variable.str_type?) || + (style == :strings && variable.any_sym_type?) end end end