File tags_helper.rb
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
module TagsHelper
# Takes an array of tags and returns a marked-up, comma-separated list of links to them
def tag_link_list(tags, link_to_works=false)
tags = tags.uniq.compact.map {|tag| content_tag(:li, link_to_works ? link_to_tag_works(tag) : link_to_tag(tag))}.join.html_safe
Method blurb_tag_block
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def blurb_tag_block(item, tag_groups=nil)
tag_groups ||= item.tag_groups
categories = ['ArchiveWarning', 'Relationship', 'Character', 'Freeform']
tag_block = ""
- 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 tag_cloud
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def tag_cloud(tags, classes)
max, min = -1.0/0, 1.0/0
tags.each { |t|
next if t.count.to_i == 0 # 0s make log scales sad
max = Math.log(t.count.to_i) if Math.log(t.count.to_i) > max
- 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 get_symbols_for
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_symbols_for(item, tag_groups=nil, symbols_only = false)
symbol_block = []
symbol_block << "<ul class=\"required-tags\">" unless symbols_only
# split up the item's tags into groups based on 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
Method get_symbols_for
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_symbols_for(item, tag_groups=nil, symbols_only = false)
symbol_block = []
symbol_block << "<ul class=\"required-tags\">" unless symbols_only
# split up the item's tags into groups based on type
Method get_warnings_class
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_warnings_class(warning_tags = [])
if warning_tags.blank? # for testing
"warning-choosenotto warnings"
elsif warning_tags.size == 1 && warning_tags.first.name == ArchiveConfig.WARNING_NONE_TAG_NAME
# only one tag and it says "no warnings"
- 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 link_to_tag_works_with_text
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def link_to_tag_works_with_text(tag, link_text, options = {})
collection = options[:collection]
if options[:full_path]
link_to_with_tag_class(collection ? collection_tag_works_url(collection, tag) : tag_works_url(tag), link_text, options)
else
- 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 get_ratings_class
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_ratings_class(rating_tags = [])
if rating_tags.blank? # for testing
"rating-notrated rating"
else
names = rating_tags.collect(&:name)
- 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 meta_tag_tree
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def meta_tag_tree(tag)
meta_ul = "".html_safe
unless tag.direct_meta_tags.empty?
tag.direct_meta_tags.each do |meta|
meta_ul += content_tag(:li, link_to_tag(meta))
- 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 sub_tag_tree
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sub_tag_tree(tag)
sub_ul = ""
unless tag.direct_sub_tags.empty?
sub_ul << "<ul class='tags tree index'>"
tag.direct_sub_tags.each do |sub|
- 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 wrangler_list
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def wrangler_list(wranglers, tag)
if wranglers.blank?
if @tag[:type] == 'Fandom'
sign_up_fandoms = tag.name
elsif Tag::USER_DEFINED.include?(@tag.class.name) && !tag.fandoms.blank?
- 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"