Sha256: 8dc5af7450fb0abae0c5164512f993c7f514b4fe1d9b840604e666aa84120ded
Contents?: true
Size: 1.18 KB
Versions: 14
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Lint # `BigDecimal.new()` is deprecated since BigDecimal 1.3.3. # This cop identifies places where `BigDecimal.new()` # can be replaced by `BigDecimal()`. # # @example # # bad # BigDecimal.new(123.456, 3) # # # good # BigDecimal(123.456, 3) # class BigDecimalNew < Cop MSG = '`%<double_colon>sBigDecimal.new()` is deprecated. ' \ 'Use `%<double_colon>sBigDecimal()` instead.' def_node_matcher :big_decimal_new, <<-PATTERN (send (const ${nil? cbase} :BigDecimal) :new ...) PATTERN def on_send(node) return unless big_decimal_new(node) do |captured_value| double_colon = captured_value ? '::' : '' message = format(MSG, double_colon: double_colon) add_offense(node, location: :selector, message: message) end end def autocorrect(node) lambda do |corrector| corrector.remove(node.loc.selector) corrector.remove(node.loc.dot) end end end end end end
Version data entries
14 entries across 14 versions & 2 rubygems