Skip to content

#push and #insert_all mutate their original input #6

Open
@benjaminjackson

Description

@benjaminjackson

The #process_kpi method mutates the original options hash, which can cause unexpected results if the calling function isn't aware of this detail:

options.delete_if { |k, _| [:date, 'date'].include?(k) }
%i{key value}.each do |k|
raise("Missing '#{k}'") if (options[k] || options[k.to_s]).nil?
end
options["$#{(options['key'] || options[:key])}"] = options['value'] || options[:value]
options.delete_if { |k, _| [:key, 'key', :value, 'value'].include?(k) }
attributes = options[:attributes] || options['attributes']
unless attributes.nil?
[:attributes, 'attributes'].each {|k| options.delete(k) }
attributes.each { |k,v| options[k] = v }
end
options

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions