class Rubocop::Cop::Style::FavorSprintf
This cop checks for uses of String#%.
It cannot be implemented in a reliable manner for all cases, so only two scenarios are considered - if the first argument is a string literal and if the second argument is an array literal.
Constants
- MSG
Public Instance Methods
on_send(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/favor_sprintf.rb, line 14 def on_send(node) receiver_node, method_name, *arg_nodes = *node if method_name == :% && ([:str, :dstr].include?(receiver_node.type) || arg_nodes[0].type == :array) add_offence(:convention, node.loc.selector, MSG) end super end