From 11e11cd219a701036724bbd32f2a18eb437b07da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lax=20Alves?= Date: Wed, 13 Dec 2017 20:48:48 -0200 Subject: [PATCH] Refactoring methods name --- app/helpers/metric_helper.rb | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/helpers/metric_helper.rb b/app/helpers/metric_helper.rb index 15179d0..e634efc 100644 --- a/app/helpers/metric_helper.rb +++ b/app/helpers/metric_helper.rb @@ -26,6 +26,7 @@ def get_metrics(grade) def calculate_metrics(release) sprint = release.sprints.last + if sprint.blank? || sprint.stories.blank? return nil else @@ -53,19 +54,19 @@ def calculate_metrics(release) set_ideal_line(days_of_sprint, ideal_line, total_points) ideal_burned_points = ideal_line[0] - ideal_line[1] - for i in 0..(date_axis.length - 2) - real_burned_points = points_axis[i] - points_axis[i + 1] + for date in 0..(date_axis.length - 2) + real_burned_points = points_axis[date] - points_axis[date + 1] burned_percentage = Float((real_burned_points).abs * 100) / ideal_burned_points metric_burndown_array.push(burned_percentage) end - for i in 0..(amount_of_sprints - 1) - metric_velocity_value += (total_sprints_points[i] - velocities[i]) + for sprint_amount in 0..(amount_of_sprints - 1) + metric_velocity_value += (total_sprints_points[sprint_amount] - velocities[sprint_amount]) end - for i in 0..(release.sprints.length - 1) - planned_points += velocity[:total_points][i] - burned_points += velocity[:completed_points][i] + for release_amount in 0..(release.sprints.length - 1) + planned_points += velocity[:total_points][release_amount] + burned_points += velocity[:completed_points][release_amount] end metric_burndown_value = calculate_burndown(metric_burndown_array) @@ -102,19 +103,19 @@ def calculate_velocity_and_debt(metric) return values end - def calculate_burndown(metric) + def calculate_burndown(metrics) values = 0 - for i in 0..(metric.length - 1) - if metric[i] <= 10 || metric[i] >= 200 + for metric in 0..(metrics.length - 1) + if metrics[metric] <= 10 || metrics[metric] >= 200 values += 0 - elsif metric[i] <= 40 + elsif metrics[metric] <= 40 values += 1 - elsif metric[i] <= 60 + elsif metrics[metric] <= 60 values += 2 - elsif metric[i] <= 80 + elsif metrics[metric] <= 80 values += 3 - elsif metric[i] <= 100 + elsif metrics[metric] <= 100 values += 4 end end