]> source.dussan.org Git - redmine.git/commitdiff
Fixes RuboCop offense Performance/Sum (#24457, #4682).
authorMarius Balteanu <marius.balteanu@zitec.com>
Thu, 2 May 2024 21:35:16 +0000 (21:35 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Thu, 2 May 2024 21:35:16 +0000 (21:35 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22805 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/version.rb

index e1525f9a0cbb15deb0d0235c58ba7a2894ad39da..ec1a9f77b53426c73ed8fe7fb07281c958ff48ef 100644 (file)
@@ -80,7 +80,7 @@ module FixedIssuesExtension
     if @estimated_average.nil?
       issues_with_total_estimated_hours = select {|c| c.total_estimated_hours.to_f > 0.0}
       if issues_with_total_estimated_hours.any?
-        average = issues_with_total_estimated_hours.map(&:total_estimated_hours).sum.to_f / issues_with_total_estimated_hours.count
+        average = issues_with_total_estimated_hours.sum(&:total_estimated_hours).to_f / issues_with_total_estimated_hours.count
       else
         average = 1.0
       end
@@ -100,12 +100,12 @@ module FixedIssuesExtension
     @issues_progress[open] ||= begin
       progress = 0
       if count > 0
-        done = open(open).map {|c|
+        done = open(open).sum do |c|
           estimated = c.total_estimated_hours.to_f
           estimated = estimated_average unless estimated > 0.0
           ratio = c.closed? ? 100 : (c.done_ratio || 0)
           estimated * ratio
-        }.sum
+        end
         progress = done / (estimated_average * count)
       end
       progress