app/models/design.rb
Class has too many lines. [116/100] Open
Open
class Design < ApplicationRecord
extend FriendlyId
include Taggable
include Sortable
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Cyclomatic complexity for sort_by_attribute is too high. [7/6] Open
Open
def sort_by_attribute(method)
case method.to_s
when 'downloads_count_desc' then reorder(downloads_count: :desc)
when 'downloads_count_asc' then reorder(downloads_count: :asc)
when 'likes_count_desc' then reorder(likes_count: :desc)
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.