Method initialize_user
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def initialize_user
@cartodb_user = ::User.new
@cartodb_user.username = username
@cartodb_user.email = email
@cartodb_user.crypted_password = crypted_password
- 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 UserCreation
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Carto::UserCreation < ActiveRecord::Base
# Synced with CartoGearsApi::Events::UserCreationEvent
CREATED_VIA_SAML = 'saml'.freeze
CREATED_VIA_LDAP = 'ldap'.freeze
File user_creation.rb
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cartodb-common'
require_dependency 'carto/user_authenticator'
class Carto::UserCreation < ActiveRecord::Base
Method new_user_signup
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.new_user_signup(user, created_via = CREATED_VIA_ORG_SIGNUP)
# Normal validation breaks state_machine method generation
raise 'User needs username' unless user.username
raise 'User needs email' unless user.email
raise "Not valid #{created_via}: #{VALID_CREATED_VIA.join(', ')}" unless VALID_CREATED_VIA.include?(created_via)
- 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 initialize_user
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize_user
@cartodb_user = ::User.new
@cartodb_user.username = username
@cartodb_user.email = email
@cartodb_user.crypted_password = crypted_password
Method close_creation
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def close_creation
clean_password
cartodb_user.notify_new_organization_user unless has_valid_invitation?
cartodb_user.organization.notify_if_disk_quota_limit_reached if cartodb_user.organization && !cartodb_user.viewer?
cartodb_user.organization.notify_if_seat_limit_reached if cartodb_user.organization && !cartodb_user.viewer?
- 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 promote_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def promote_user
return unless @promote_to_organization_owner
organization = Carto::Organization.find_by(id: organization_id)
raise "Trying to set organization owner when there's already one" unless organization.owner.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 clean_user
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clean_user
return unless cartodb_user && !cartodb_user.id.nil?
begin
cartodb_user.destroy
- 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"