Actions
Patch #44759
openUse Comparable#clamp to limit the number of rows in the description and notes fields
Patch #44759:
Use Comparable#clamp to limit the number of rows in the description and notes fields
Status:
New
Priority:
Normal
Assignee:
-
Category:
Code cleanup/refactoring
Target version:
Description
The number of rows in the issue description field and the notes field of the journal edit form is limited with nested Array#max and Array#min:
This code dates back to 2006-2008. At that time, Ruby did not provide a method for limiting a value to a range. Comparable#clamp, which was introduced in Ruby 2.4 released in 2016, allows the same limit to be written more simply.
The attached patch replaces these expressions with Comparable#clamp:
Unlike the original code, it does not create temporary arrays, and both the lower and upper limits are visible at a glance.
Files
No data to display
Actions