diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2019-10-17 15:28:57 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2019-10-17 15:28:57 +0000 |
commit | a7b568ccff3ba21e87179feea7ede8acbe0b8875 (patch) | |
tree | 84986b7e8eff3a55e87b932b731adbd44baa4427 | |
parent | d4a428f11edad6b2f3b9f394151024f918d9e48c (diff) | |
download | redmine-a7b568ccff3ba21e87179feea7ede8acbe0b8875.tar.gz redmine-a7b568ccff3ba21e87179feea7ede8acbe0b8875.zip |
code cleanup: rubocop: fix Layout/CommentIndentation and Style/NestedTernaryOperator in app/helpers/versions_helper.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@18714 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | .rubocop_todo.yml | 2 | ||||
-rw-r--r-- | app/helpers/versions_helper.rb | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7d4888452..9bd741400 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -91,7 +91,6 @@ Layout/ClosingParenthesisIndentation: # Cop supports --auto-correct. Layout/CommentIndentation: Exclude: - - 'app/helpers/versions_helper.rb' - 'app/models/mailer.rb' - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' - 'test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb' @@ -1174,7 +1173,6 @@ Style/NestedParenthesizedCalls: Style/NestedTernaryOperator: Exclude: - 'app/helpers/queries_helper.rb' - - 'app/helpers/versions_helper.rb' - 'app/models/issue_relation.rb' - 'app/models/journal.rb' diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 35d9b6d00..03bd454bb 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -54,7 +54,6 @@ module VersionsHelper def render_issue_status_by(version, criteria) criteria = 'tracker' unless STATUS_BY_CRITERIAS.include?(criteria) - h = Hash.new {|k,v| k[v] = [0, 0]} begin # Total issue count @@ -62,12 +61,22 @@ module VersionsHelper # Open issues count version.visible_fixed_issues.open.group(criteria).count.each {|c,s| h[c][1] = s} rescue ActiveRecord::RecordNotFound - # When grouping by an association, Rails throws this exception if there's no result (bug) + # When grouping by an association, Rails throws this exception if there's no result (bug) end # Sort with nil keys in last position - counts = h.keys.sort {|a,b| a.nil? ? 1 : (b.nil? ? -1 : a <=> b)}.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}} + sorted_keys = + h.keys.sort {|a, b| + if a.nil? + 1 + else + b.nil? ? -1 : a <=> b + end + } + counts = + sorted_keys.collect {|k| + {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])} + } max = counts.collect {|c| c[:total]}.max - render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max} end |