Showing 36 of 63 total issues
Method initialize
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
user = User.new if user.nil?
#
#guest
- 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 User
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
delegate :can?, :cannot?, :to => :ability
STATUS_ANONYMOUS = 0
Function tagit
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.tagit = function(options) {
var el = this;
create_preview()
function split( val ) {
return val.split(/[\s]+/);
Method initialize
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
user = User.new if user.nil?
#
#guest
Method find_or_create
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def self.find_or_create(*args)
return false unless APP_CONFIG['gain_achievements']
name = args[0]
user = args[1][:user]
- 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 vote
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def vote(voter,vote) # self.user # thr owner
unless ["up","down"].include?(vote)
errors[:base] << I18n.t("voteable.bad_param")
return false
- 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_for_vote_up
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def achievement_for_vote_up
if activityable.class.name == 'Thr' # ask
if activityable.vote_count >= APP_BADGES_CONFIG['nice_question']
# uniq_activityable for each thr, an or comment
- 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 sortable
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.sortable(sort_by={})
default = [:created_at,:desc].join(" ")
valid = ['created_at','uploaded_at','sizebyte','name']
return order(default) if sort_by.nil?
sortable = []
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
def create
@thr = Thr.new
@thr.title = params[:thr][:title]
@thr.content = params[:thr][:content]
- 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 change_password
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def change_password
# check hash
@user = User.active.where(:remind_token=>params[:hash]).first
if @user.nil?
redirect_to root_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
Method login_with_omniauth
has 32 lines of code (exceeds 25 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
Method set_tags
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def set_tags
return unless self.tagnames
tags_arr = tags_array_from_string
self.tagnames = tags_arr.join(' ')
return unless self.tagnames_changed?
- 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 vote
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vote(voter,vote) # self.user # thr owner
unless ["up","down"].include?(vote)
errors[:base] << I18n.t("voteable.bad_param")
return false
Method achievement_for_vote_up
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def achievement_for_vote_up
if activityable.class.name == 'Thr' # ask
if activityable.vote_count >= APP_BADGES_CONFIG['nice_question']
# uniq_activityable for each thr, an or comment
Method sortable
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def sortable(column, title = nil)
title ||= column.titleize
sort_param = params[:sort].nil? ? []:params[:sort]
css_class = sort_param.include?(column) ? "current #{sort_param[column]}" : nil
direction = sort_param.include?(column) && sort_param[column] == "asc" ? "desc" : "asc"
- 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 set_activity_for_thr
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_activity_for_thr(thr)
thr.last_activity_user_id = user_id
thr.last_activity_id = id
set_activity_for(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 answer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def answer
show_action
if request.post?
- 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 change_password
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change_password
# check hash
@user = User.active.where(:remind_token=>params[:hash]).first
if @user.nil?
redirect_to root_url
Method convert_and_pass_on
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_and_pass_on(env)
if env['rack.input'].kind_of?(Tempfile)
tempfile = env['rack.input']
else
tempfile = Tempfile.new('raw-upload.')
Method set_activity_at_for_activityable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_activity_at_for_activityable
if ['create','delete','revise','an_resolved','an_unresolved','close'].include? name
if activityable.class == Thr
set_activity_for_thr(activityable)
elsif activityable.class == An
- 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"