Class SessionsController
has 39 methods (exceeds 20 allowed). Consider refactoring. Open
class SessionsController < ApplicationController
include ActionView::Helpers::DateHelper
include LoginHelper
include Carto::EmailCleaner
File sessions_controller.rb
has 361 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_dependency 'carto/oauth/github/config'
require_dependency 'carto/oauth/google/config'
require_dependency 'carto/saml_service'
require_dependency 'carto/username_proposer'
require_dependency 'carto/email_cleaner'
Method create_user
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create_user(params = {}, &config_account_creator_block)
@organization = Carto::Organization.find(params[:organization_id])
account_creator = CartoDB::UserAccountCreator.new(params[: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 new
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def new
if current_viewer
redirect_to(CartoDB.url(self, 'dashboard', params: { trailing_slash: true }, user: current_viewer))
elsif saml_authentication? && !user
# Automatically trigger SAML request on login view load -- could easily trigger this elsewhere
- 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 multifactor_authentication_verify_code
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def multifactor_authentication_verify_code
user = ::User.where(id: params[:user_id]).first
url = after_login_url(user)
if params[:skip] == "true" && user.active_multifactor_authentication.needs_setup?
- 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 saml_logout
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def saml_logout
# IDP-initiated logout request
if params[:SAMLRequest]
redirect_to saml_service.idp_logout_request(params[:SAMLRequest], params[:RelayState]) { cdb_logout }
# IDP-initiated logout response
- 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 8 (exceeds 5 allowed). Consider refactoring. Open
def create
strategies, username = saml_strategy_username || ldap_strategy_username || credentials_strategy_username
unless strategies
return saml_authentication? ? render_403 : render(action: 'new')
- 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 unauthenticated
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def unauthenticated
username = extract_username(request, params)
CartoDB::Stats::Authentication.instance.increment_failed_login_counter(username)
# Use an instance variable to show the error instead of the flash hash. Setting the flash here means setting
- 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 extract_username
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def extract_username(request, params)
# params[:email] can contain a username
email = params[:email]
username = if email.present?
email.include?('@') ? username_from_user_by_email(params[:email]) : 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"