Fix Performance/HashEachMethods offenses

values.each and keys.each methods are depreciated, so they have replaced by
each_value and each_key respectively. This has done manually.

Closes https://github.com/openSUSE/osem/issues/1825
This commit is contained in:
Ronaq13 2017-12-09 14:03:59 +05:30 committed by Ana María Martínez Gómez
parent 99ab06d117
commit 505d9da3d4
6 changed files with 6 additions and 15 deletions

View file

@ -376,15 +376,6 @@ Naming/VariableNumber:
Exclude:
- 'spec/models/ticket_purchase_spec.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Performance/HashEachMethods:
Exclude:
- 'app/controllers/admin/conferences_controller.rb'
- 'app/helpers/application_helper.rb'
- 'db/migrate/20140701123203_add_events_per_week_to_conference.rb'
- 'spec/factories/event_users.rb'
# Offense count: 1
# Cop supports --auto-correct.

View file

@ -155,7 +155,7 @@ module Admin
# Set line color using a hash function
@tickets = []
@tickets_data.keys.each do |title|
@tickets_data.each_key do |title|
@tickets.append(short_title: title, color: "\##{Digest::MD5.hexdigest(title)[0..5]}")
end

View file

@ -99,7 +99,7 @@ module ApplicationHelper
end
def normalize_array_length(hashmap, length)
hashmap.each do |_, value|
hashmap.each_value do |value|
if value.length < length
value.fill(value[-1], value.length...length)
end

View file

@ -9,10 +9,10 @@
%timeslot_duration= length_timestamp(@conference.program.schedule_interval)
- if @events_xml.any?
- @events_xml.keys.each.with_index(1) do |day, index|
- @events_xml.each_key.with_index(1) do |day, index|
%day{ date: day, index: index }
- events_in_rooms = @events_xml[day].group_by(&:room)
- events_in_rooms.keys.each do |room|
- events_in_rooms.each_key do |room|
%room{ name: room.name }
- events_in_rooms[room].each do |event|
%event{ guid: event.guid, id: event.id }

View file

@ -77,7 +77,7 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration
hash.each do |week, values|
if previous
values.each do |state, _value|
values.each_key do |state|
hash[week][state] += previous[state]
end
end

View file

@ -4,7 +4,7 @@ FactoryGirl.define do
factory :event_user do
user
Hash[EventUser::ROLES].values.each do |role|
Hash[EventUser::ROLES].each_value do |role|
factory role do
event_role role
end