Sha256: 8a96d0b3ef38a7f1338c398c3d3fcd582225320d58d40c464644e24bb8cc0aa5
Contents?: true
Size: 779 Bytes
Versions: 2
Compression:
Stored size: 779 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Lint # This cop checks for string conversion in string interpolation, # which is redundant. # # @example # # "result is #{something.to_s}" class StringConversionInInterpolation < Cop MSG = 'Redundant use of Object#to_s in interpolation.' def on_dstr(node) node.children.select { |n| n.type == :begin }.each do |begin_node| final_node = begin_node.children.last next unless final_node.type == :send _receiver, method_name, *args = *final_node if method_name == :to_s && args.empty? add_offense(final_node, :selector) end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/lint/string_conversion_in_interpolation.rb |
rubocop-0.19.0 | lib/rubocop/cop/lint/string_conversion_in_interpolation.rb |