CartoDB/cartodb20

View on GitHub
app/controllers/sessions_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Class SessionsController has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

class SessionsController < ApplicationController
  include ActionView::Helpers::DateHelper
  include LoginHelper
  include Carto::EmailCleaner

Severity: Minor
Found in app/controllers/sessions_controller.rb - About 5 hrs to fix

    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'
    Severity: Minor
    Found in app/controllers/sessions_controller.rb - About 4 hrs to fix

      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])
      
      
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 1 hr to fix

      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?
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 45 mins to fix

      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')
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 45 mins to fix

      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
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 35 mins to fix

      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
      Severity: Minor
      Found in app/controllers/sessions_controller.rb - About 25 mins to fix

      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

      There are no issues that match your filters.

      Category
      Status