From 57743df197b99ef8f7080a13dbb2999a84972be2 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:22:47 +0100 Subject: [PATCH] Enable rubocop Performance/HashEachMethods cop & fix issues --- .rubocop.yml | 3 +++ app/models/ahoy/data_source.rb | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 340b672f4..00acb14ea 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -73,6 +73,9 @@ Performance/FixedSize: Performance/FlatMap: Enabled: true +Performance/HashEachMethods: + Enabled: true + Performance/LstripRstrip: Enabled: true diff --git a/app/models/ahoy/data_source.rb b/app/models/ahoy/data_source.rb index 9195d0ff1..ba8a2cf14 100644 --- a/app/models/ahoy/data_source.rb +++ b/app/models/ahoy/data_source.rb @@ -10,12 +10,12 @@ module Ahoy # chart def add(name, collection) collections.push data: collection, name: name - collection.each{ |k, v| add_key k } + collection.each_key{ |key| add_key key } end def build data = { x: [] } - keys.each do |k| + shared_keys.each do |k| # Add the key with a valid date format data[:x].push k.strftime("%Y-%m-%d") @@ -36,12 +36,12 @@ module Ahoy @collections ||= [] end - def keys - @keys ||= [] + def shared_keys + @shared_keys ||= [] end def add_key(key) - keys.push(key) unless keys.include? key + shared_keys.push(key) unless shared_keys.include? key end end