app/helpers/synapses_helper.rb
Method has too many lines. [12/10] Open
Open
def autocomplete_synapse_array_json(synapses)
synapses.map do |s|
{
id: s.id,
label: s.desc.blank? ? '(no description)' : s.desc,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Use s.desc.presence || '(no description)'
instead of s.desc.blank? ? '(no description)' : s.desc
. Open
Open
label: s.desc.blank? ? '(no description)' : s.desc,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks code that can be written more easily using
Object#presence
defined by Active Support.
Example:
# bad
a.present? ? a : nil
# bad
!a.present? ? nil : a
# bad
a.blank? ? nil : a
# bad
!a.blank? ? a : nil
# good
a.presence
Example:
# bad
a.present? ? a : b
# bad
!a.present? ? b : a
# bad
a.blank? ? b : a
# bad
!a.blank? ? a : b
# good
a.presence || b