app/helpers/maps_helper.rb
Method has too many lines. [15/10] Open
Open
def autocomplete_map_array_json(maps)
maps.map do |m|
{
id: m.id,
label: m.name,
- 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.
Method has too many lines. [11/10] Open
Open
def contributor_tip(map)
output = ''
if map.contributors.count.positive?
map.contributors.each_with_index do |contributor, _index|
user_image = contributor.image.url(:thirtytwo)
- 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.
Favor modifier if
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. Open
Open
if map.contributors.count.positive?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for if and unless statements that would fit on one line
if written as a modifier if/unless. The maximum line length is
configured in the Metrics/LineLength
cop.
Example:
# bad
if condition
do_stuff(bar)
end
unless qux.empty?
Foo.do_something
end
# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?