Add and apply Style/MapToHash rubocop rule

This rule was added in Rubocop 1.24.0. Applying it slightly simplifies
the code.
This commit is contained in:
Javi Martín
2022-08-25 22:24:36 +02:00
parent 5ec7f4a339
commit 4a851c0d82
7 changed files with 16 additions and 13 deletions

View File

@@ -95,7 +95,7 @@ module Statisticable
end
def participants_by_age
age_groups.map do |start, finish|
age_groups.to_h do |start, finish|
count = participants.between_ages(start, finish).count
[
@@ -106,11 +106,11 @@ module Statisticable
percentage: calculate_percentage(count, total_participants)
}
]
end.to_h
end
end
def participants_by_geozone
geozone_stats.map do |stats|
geozone_stats.to_h do |stats|
[
stats.name,
{
@@ -118,7 +118,7 @@ module Statisticable
percentage: stats.percentage
}
]
end.to_h
end
end
def calculate_percentage(fraction, total)