Class User
has 43 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :encryptable,
:recoverable, :rememberable, :trackable
File user.rb
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'digest/md5'
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :encryptable,
Method schedule_tasks
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def schedule_tasks(options={})
options[:limit] ||= 1000000
options[:save] = true unless options.key?(:save)
if options[:save]
- 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_widgets
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_widgets
w = new_widget
w.name = I18n.t('widgets.top_tasks')
w.widget_type = 0
w.number = 5
Method avatar_url
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def avatar_url(size=32, secure = false)
if avatar?
if size > 25 && File.exist?(avatar_large_path)
'/users/avatar/'+id.to_s+'?large=1'
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 can?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def can?(project, perm)
return true if project.nil? or admin?
@perm_cache ||= {}
unless @perm_cache[project.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"