I have a where method in model that's throwing lint error. The whole code in model is just a test code at this moment and will be refactored later on. So i want to turn off this lint error for now.
UPDATE: Here's the method i am getting lint error at
def self.where(start_date, end_date, customer_id, type, location, is_registered)
filtered_data = if start_date && end_date
customers.select do |e|
e[:startDateTime].to_datetime >= start_date.to_datetime &&
e[:endDateTime].to_datetime <= end_date.to_datetime
end
elsif start_date
customers.select {|e| e[:startDateTime].to_datetime >= start_date.to_datetime }
elsif end_date
customers.select {|e| e[:endDateTime].to_datetime <= end_date.to_datetime }
else
customers
end
if !is_registered.nil? # is_registered is true or false
filtered_data = customers.select { |e| e[:isRegistered].to_s == is_registered }
end
# Check if hash presents and check if the keys have valid values.
if customer_id || type || location
hash = { customerId: customer_id.to_i, type: type, location: location }
# delete if type, location or customer_id is nil.
hash = hash.delete_if { |_k, v| v.nil? || v == 0 }
keys = hash.keys
filtered_data = filtered_data.select { |h| h.select { |k| keys.include?(k) } == hash }
else
filtered_data
end
filtered_data.map do |slot|
mock_customer(slot[:id], slot[:customerId], slot[:name], slot[:startDateTime],
slot[:endDateTime], slot[:location], slot[:status])
end
end
I tried adding # rubocop:disable Metrics/AbcSize
in model but didnt help.