Showing 36 of 63 total issues
Method set_achievement
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_achievement
self.increment!(:hotness)
self.increment!(:hits)
# impressionable.reload # reload hits, hotness
if self.class.name == 'Thr'
- 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 login_with_email_and_pass
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def login_with_email_and_pass
if request.post? && params[:login] && params[:login][:email] && params[:login][:password]
if params[:login][:email].blank? || params[:login][:password].blank?
flash[:login_error] = t :all_fields_required
redirect_to login_index_url
- 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
Consider simplifying this complex logical expression. Open
if (sub.user.user_setting.notify_answers==1 && answer_created?) ||
(sub.user.user_setting.notify_comments==1 && comment_created?) ||
(sub.user.user_setting.notify_answer_resolved==1 && answer_resolved?)
p "send mail to #{sub.user.name}"
Method create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create
@user = User.new
@user.accessible = :all if current_user.is_admin?
@user.name = params[:user][:name]
@user.email = params[:user][:email]
- 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 auth_failed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def auth_failed(notice=nil)
notice = notice.split(' base ').last if notice.include? 'base'
notice = notice.nil? ? t(:unauthorized_http) : notice
respond_to do |format|
format.html {
- 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 check_flagging_and_closing
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_flagging_and_closing
if flagging?
if self.user.activities.flagged_today.count > APP_VOTING_CONFIG['max_flag_par_day']
errors.add(:base,:too_many_reports)
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 field_messages_for
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def field_messages_for(model, attribute=nil)
if model && attribute
err = model.errors[attribute]
err = err.first if err.is_a?(Array)
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 update
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update
@thr = Thr.find(params[:id])
@thr.title = params[:thr][:title] if can?(:edit, @thr)
@thr.content = params[:thr][:content] if can?(:edit, @thr)
- 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 achievement_schema
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def achievement_schema(*args)
if args[0].class.name.constantize < ActiveRecord::Base
object = args[0]
tname = object.name_humanized
name = object.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 build_points
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build_points(hash)
if hash[:user_id]
if points_receiver(hash[:user_id])
if ActivityPoint.not_undo.where(:user_id=>hash[:user_id]).
created_today.sum(:value) >= APP_REPUTATION['max_rep_by_up_votes']
- 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 unified_errors
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def unified_errors(model,attribute=nil)
if model && attribute
err = model.errors[attribute]
err = err.first if err.is_a?(Array)
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
Avoid too many return
statements within this method. Open
return false
Method achievement_for_delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def achievement_for_delete
if activityable.class.name == 'Thr'
if activityable.user_id == user.id && activityable.vote_count >= APP_BADGES_CONFIG['disciplined']
Achievement.find_or_create('disciplined',:user=>user,:activity=>self)
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 ako
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ako
# params[:k] - api key
# params[:opt] - option / unckeck all subscribed field / uncheck question only
# params[:opt_id] - option id
@user = User.active.find_by_apikey!(params[:k])
- 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 login_with_omniauth
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def login_with_omniauth
omniauth = request.env["omniauth.auth"]
authentication = Authentication.find_by_provider_and_uid(omniauth['provider'],omniauth['uid'])
if authentication
# jesli uid juz istnieje loguje odrazu
- 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 log_impression
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def log_impression(ip,user=nil)
unless APP_CONFIG['unique_impressions']
set_achievement
return
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"