Showing 132 of 189 total issues
Method perform
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def perform(spammable)
return if Rails.env.test? || Rails.env.development?
begin
thing_to_analyze = spammable['klass'].classify.constantize.find(spammable['id'])
- 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 associate_event_fact
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def associate_event_fact(fact)
if fact.tagged?('event')
tokenized_tags = fact.tags.map { |t| Skill.tokenize(t) }
if tokenized_tags.include?(tokenized)
if fact.tagged?('spoke')
- 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 destination_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def destination_url
if session[:return_to]
session.delete(:return_to)
elsif signed_in?
if current_user.oldest_achievement_since_last_visit
- 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 show
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def show
@team = Team.find(params[:id])
invitation_failed! unless @team.has_user_with_referral_token?(params[:r])
store_location! unless signed_in?
session[:referred_by] = params[:r]
- 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
Avoid too many return
statements within this method. Open
return photos['Nowhere']
Method reverse_geocode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def reverse_geocode(ip_address)
uri = URI::HTTP.build(scheme: 'http',
host: 'geoip.maxmind.com',
path: @service_path,
query: URI.encode_www_form(l: @license,
- 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 avatar_url_for
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def avatar_url_for(oauth)
if oauth[:extra] && oauth[:extra][:raw_info] && oauth[:extra][:raw_info][:gravatar_id]
"https://secure.gravatar.com/avatar/#{oauth[:extra][:raw_info][:gravatar_id]}"
elsif oauth[:info]
if oauth['provider'] == 'twitter'
- 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 already_voted?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def already_voted?(voter, tracking, ip_address)
existing_upvote = likes.where(user_id: voter.id).first unless voter.nil?
existing_upvote = likes.where(tracking_code: tracking).first if existing_upvote.nil? and tracking
existing_upvote = likes.where(ip_address: ip_address).first if existing_upvote.nil? and voter.nil? and (tracking.nil? || !User.exists?(tracking_code: tracking))
- 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 linkedin_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def linkedin_url(user)
if !user.linkedin_public_url.blank?
user.linkedin_public_url
elsif !user.linkedin.blank?
"http://www.linkedin.com/in/#{user.linkedin}"
- 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 message_to_create_ehanced_team
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def message_to_create_ehanced_team
if signed_in? && !current_user.team.nil?
"Is #{current_user.team.name} awesome and hiring? Enhance your team's profile here. Hiring teams are visited by 7X more developers" unless current_user.team.try(:hiring?) == true
else
"Have an amazing team that is hiring? Setup your team's profile."
- 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 update
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update
# strong_parameters will intentionally fail if a key is present but has an empty hash. :(
update_params = if params[:protip] && params[:protip].keys.present?
params.require(:protip).permit(:title, :body, :user_id, :topic_list)
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 find_with_oauth
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_with_oauth(oauth)
case oauth[:provider]
when 'github'
(oauth[:uid] ? find_by_github_id(oauth[:uid]) : find_by_github(oauth[:info][:nickname]))
when 'linkedin'
- 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"
Further reading
Method create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create
redirect_to teamname_path(slug: @team.slug) if @plan.free?
@account = @team.build_account(account_params)
- 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 delivered
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def delivered
Rails.logger.info("Mailgun Delivered: #{params.inspect}")
if mailgun?(ENV['MAILGUN_API_KEY'], params['token'], params['timestamp'], params['signature'])
if params[:event] = "delivered"
user = User.where(email: params[:recipient]).first
- 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 perform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def perform(user_id)
begin
user = User.find(user_id)
return if user.active?
- 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 generate_event
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_event(event_type, audience, data={}, drip_rate=:immediately)
data.merge!({ event_type: event_type }.with_indifferent_access)
data = { version: VERSION, event_id: Time.now.utc.to_i }.with_indifferent_access.merge(data)
data.deep_merge!(extra_information(data))
drip_rate = :immediately if drip_rate.nil?
- 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 visitors
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def visitors(since = 0)
detailed_visitors = self.detailed_visitors
first_detailed_visit = detailed_visitors.last.nil? ? updated_at : detailed_visitors.first[:visited_at]
self.detailed_visitors(since) + simple_visitors(since == 0 ? first_detailed_visit.to_i : since)
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 generate_event
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_event(options={})
event_type = event_type(options)
data = to_event_hash(options)
GenerateEventJob.perform_async(event_type, event_audience(event_type), data, 1.minute)
- 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 images
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def images
if self.new_record?
self.links.select { |link| ProtipLink.is_image? link }
else
if protip_links.loaded?
- 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"