File protips_helper.rb
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cfm'
module ProtipsHelper
def protip_search_results_to_render(protips)
Method protip_topic_page_title
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def protip_topic_page_title(topics)
username = topics.is_a?(Array) ? (topics.size == 1 ? topics.first : nil) : topics
unless username.nil? or (user = User.find_by_username(username)).blank?
"Coderwall - Trending Pro tips by #{user.name}"
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 topics_to_query
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def topics_to_query(topics)
topics = topics.split(" + ") unless topics.nil? or topics.is_a? Array
topics.map do |topic|
if Protip::USER_SCOPE.include? topic or topic =~ /^team:/ or topic =~ /^author:/
topic
- 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 my_protips?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def my_protips?(topics)
topics.map do |topic|
if Protip::USER_SCOPE_REGEX[:author] =~ topic || Protip::USER_SCOPE_REGEX[:bookmark] =~ topic
return true
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"