class RuboCop::Cop::Lint::CircularArgumentReference
end
dry_ingredients.combine
def cook(dry_ingredients = self.dry_ingredients)
# good
@example
end
dry_ingredients.reduce(&:+)
def cook(dry_ingredients = dry_ingredients)
# bad
@example
end
pie.feed_to(user)
def bake(pie: self.pie)
# good
@example
end
pie.refrigerate
def bake(pie:)
# good
@example
end
pie.heat_up
def bake(pie: pie)
# bad
@example
This cop mirrors a warning produced by MRI since 2.2.
arguments and optional ordinal arguments.
Checks for circular argument references in optional keyword
def check_for_circular_argument_references(arg_name, arg_value)
def check_for_circular_argument_references(arg_name, arg_value) return unless arg_value.lvar_type? return unless arg_value.to_a == [arg_name] add_offense(arg_value, message: format(MSG, arg_name: arg_name)) end
def on_kwoptarg(node)
def on_kwoptarg(node) check_for_circular_argument_references(*node) end
def on_optarg(node)
def on_optarg(node) check_for_circular_argument_references(*node) end