Sha256: d828519c1c718b1f0ea3b4aef61ce4f5836b219e5ca6186d6ff40aa2d63cbc9d
Contents?: true
Size: 726 Bytes
Versions: 5
Compression:
Stored size: 726 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # 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. class FavorSprintf < Cop MSG = 'Favor sprintf over String#%.' 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) convention(node, :selector) end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems