Method assign_tags
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def assign_tags
tags_to_add = []
tags_to_remove = []
TAG_TYPES.each do |type|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Class TagSet
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class TagSet < ApplicationRecord
# a complete match is numerically represented with ALL
ALL = -1
TAG_TYPES = %w(fandom character relationship freeform category rating archive_warning)
Method tagnames_must_exist
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def tagnames_must_exist
nonexist = []
if @tagnames
nonexist += @tagnames.split(ArchiveConfig.DELIMITER_FOR_INPUT).select {|t| !Tag.where(name: t.squish).exists?}
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method tagnames_to_list
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def tagnames_to_list(taglist, type=nil)
taglist = (taglist.kind_of?(String) ? taglist.split(ArchiveConfig.DELIMITER_FOR_INPUT) : taglist).uniq
if type
raise "Redshirt: Attempted to constantize invalid class initialize tagnames_to_list #{type}" unless TAG_TYPES.include?(type)
if Tag::USER_DEFINED.include?(type.classify)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method assign_tags
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def assign_tags
tags_to_add = []
tags_to_remove = []
TAG_TYPES.each do |type|