File user.rb
has 808 lines of code (exceeds 250 allowed). Consider refactoring. Open
class User < ApplicationModel
include CanBeImported
include HasActivityStreamLog
include ChecksClientNotification
include HasHistory
Class User
has 65 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationModel
include CanBeImported
include HasActivityStreamLog
include ChecksClientNotification
include HasHistory
Method name_guess
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def self.name_guess(string, email = nil)
return if string.blank? && email.blank?
string.strip!
firstname = ''
- 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 destroy_move_dependency_ownership
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def destroy_move_dependency_ownership
result = Models.references(self.class.to_s, id)
user_columns = %w[created_by_id updated_by_id out_of_office_replacement_id origin_by_id owner_id archived_by_id published_by_id internal_by_id]
result.each do |class_name, references|
- 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 validate_agent_limit_by_role
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def validate_agent_limit_by_role(role)
return true if Setting.get('system_agent_limit').blank?
return true if active != true
return true if role.active != true
return true if !role.with_permission?('ticket.agent')
- 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 name_guess
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.name_guess(string, email = nil)
return if string.blank? && email.blank?
string.strip!
firstname = ''
Method destroy_move_dependency_ownership
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def destroy_move_dependency_ownership
result = Models.references(self.class.to_s, id)
user_columns = %w[created_by_id updated_by_id out_of_office_replacement_id origin_by_id owner_id archived_by_id published_by_id internal_by_id]
result.each do |class_name, references|
Method create_from_hash!
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_from_hash!(hash)
url = ''
hash['info']['urls']&.each_value do |local_url|
next if local_url.blank?
Method with_permissions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.with_permissions(keys)
if keys.class != Array
keys = [keys]
end
permission_ids = []
Method with_permissions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.with_permissions(keys)
if keys.class != Array
keys = [keys]
end
permission_ids = []
- 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 validate_roles
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_roles(role)
return true if !role_ids # we need role_ids for checking in role_ids below, in this method
return true if role.preferences[:not].blank?
role.preferences[:not].each do |local_role_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 validate_preferences
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_preferences
return true if !changes
return true if !changes['preferences']
return true if preferences.blank?
return true if !preferences[:notification_sound]
- 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_login
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_login
# use email as login if not given
if login.blank?
self.login = 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 check_name
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def check_name
self.firstname = sanitize_name(firstname)
self.lastname = sanitize_name(lastname)
return if firstname.present? && lastname.present?
- 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_from_hash!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.create_from_hash!(hash)
url = ''
hash['info']['urls']&.each_value do |local_url|
next if local_url.blank?
- 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 if !User.exists?(email: email.downcase.strip)
Avoid too many return
statements within this method. Open
return true
Avoid too many return
statements within this method. Open
return true if !preferences[:notification_sound][:enabled]