lib/rubocop/cop/rails/file_path.rb in rubocop-0.47.1 vs lib/rubocop/cop/rails/file_path.rb in rubocop-0.48.0

- old
+ new

@@ -15,23 +15,19 @@ # # good # Rails.root.join('app', 'models', 'goober') class FilePath < Cop MSG = 'Please use `Rails.root.join(\'path\', \'to\')` instead.'.freeze - def_node_search :file_join_nodes, <<-PATTERN + def_node_matcher :file_join_nodes?, <<-PATTERN (send (const nil :File) :join ...) PATTERN - def_node_search :file_join_nodes?, <<-PATTERN - (send (const nil :File) :join ...) - PATTERN - def_node_search :rails_root_nodes?, <<-PATTERN (send (const nil :Rails) :root) PATTERN - def_node_search :rails_root_join_nodes, <<-PATTERN + def_node_matcher :rails_root_join_nodes?, <<-PATTERN (send (send (const nil :Rails) :root) :join ...) PATTERN def on_dstr(node) return unless rails_root_nodes?(node) @@ -45,23 +41,18 @@ private def check_for_file_join_with_rails_root(node) return unless file_join_nodes?(node) - return unless file_join_nodes(node).map(&:method_args) - .flatten - .any? { |e| rails_root_nodes?(e) } + return unless node.method_args.any? { |e| rails_root_nodes?(e) } register_offense(node) end def check_for_rails_root_join_with_slash_separated_path(node) return unless rails_root_nodes?(node) - return unless rails_root_join_nodes(node).map(&:method_args) - .flatten - .any? do |arg| - arg.source =~ %r{/} - end + return unless rails_root_join_nodes?(node) + return unless node.method_args.any? { |arg| arg.source =~ %r{/} } register_offense(node) end def register_offense(node)