From 32ba4d3afedd5c984dd7e0d952c37eab1b33b80e Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Tue, 10 Nov 2026 14:52:38 +0900 Subject: [PATCH] Use Comparable#clamp instead of nested max and min for better readability The number of rows was bounded with nested Array#max and Array#min, which builds two arrays and hides the lower and upper limits inside the expression. Comparable#clamp shows both limits at a glance. Co-Authored-By: Claude Opus 5.5 --- app/views/issues/_form.html.erb | 2 +- app/views/journals/_notes_form.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 0631a4ab0..189fedac2 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -34,7 +34,7 @@ <%= f.label_for_field :description, :required => @issue.required_attribute?('description') %> <%= content_tag 'div', :id => "issue_description_and_toolbar", :style => (@issue.new_record? ? nil : 'display:none') do %> <%= f.wiki_textarea :description, :cols => 60, :accesskey => accesskey(:edit), :no_label => true, - :rows => [[10, @issue.description.to_s.length / 50].max, 20].min, + :rows => (@issue.description.to_s.length / 50).clamp(10, 20), :data => {:auto_complete => true}, :preview_url => preview_issue_path(:project_id => @issue.project, :issue_id => @issue.id) %> <% end %> diff --git a/app/views/journals/_notes_form.html.erb b/app/views/journals/_notes_form.html.erb index 2f5104ecb..39bc5619a 100644 --- a/app/views/journals/_notes_form.html.erb +++ b/app/views/journals/_notes_form.html.erb @@ -4,7 +4,7 @@ :id => "journal-#{@journal.id}-form") do %> <%= label_tag "notes", l(:description_notes), :class => "hidden-for-sighted", :for => "journal_#{@journal.id}_notes" %> <%= wiki_textarea_tag 'journal[notes]', @journal.notes, :id => "journal_#{@journal.id}_notes", - :rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min), + :rows => (@journal.notes.to_s.length / 50).clamp(10, 100), :data => {:auto_complete => true}, :preview_url => preview_issue_path(:project_id => @project, :issue_id => @journal.issue) %> <% if @journal.safe_attribute? 'private_notes' %> -- 2.55.0