Noosfero/noosfero

View on GitHub
app/controllers/public/account_controller.rb

Summary

Maintainability
F
3 days
Test Coverage

File account_controller.rb has 426 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class AccountController < ApplicationController
  no_design_blocks

  before_action :login_required, :require_login_for_environment, only: [:activation_question, :accept_terms, :activate_enterprise, :change_password]
  before_action :redirect_if_logged_in, only: [:login, :signup, :activate]
Severity: Minor
Found in app/controllers/public/account_controller.rb - About 6 hrs to fix

    Class AccountController has 35 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class AccountController < ApplicationController
      no_design_blocks
    
      before_action :login_required, :require_login_for_environment, only: [:activation_question, :accept_terms, :activate_enterprise, :change_password]
      before_action :redirect_if_logged_in, only: [:login, :signup, :activate]
    Severity: Minor
    Found in app/controllers/public/account_controller.rb - About 4 hrs to fix

      Method signup has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def signup
          if @plugins.dispatch(:allow_user_registration).include?(false)
            redirect_back_or_default(controller: "home")
            session[:notice] = _("This environment doesn't allow user registration.")
            return
      Severity: Minor
      Found in app/controllers/public/account_controller.rb - About 2 hrs 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 activate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def activate
          @user = User.find_by(activation_code: params[:activation_token])
      
          if @user.nil?
            session[:notice] = _("We couldn't find an account to be activated. "\
      Severity: Minor
      Found in app/controllers/public/account_controller.rb - About 2 hrs 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 login has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def login
          store_location(request.referer) unless params[:return_to] || session[:return_to]
      
          return unless request.post?
      
      
      Severity: Minor
      Found in app/controllers/public/account_controller.rb - About 2 hrs 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 signup has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def signup
          if @plugins.dispatch(:allow_user_registration).include?(false)
            redirect_back_or_default(controller: "home")
            session[:notice] = _("This environment doesn't allow user registration.")
            return
      Severity: Minor
      Found in app/controllers/public/account_controller.rb - About 1 hr to fix

        Method forgot_password has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def forgot_password
            if @plugins.dispatch(:allow_password_recovery).include?(false)
              redirect_back_or_default(controller: "home")
              session[:notice] = _("This environment doesn't allow password recovery.")
            end
        Severity: Minor
        Found in app/controllers/public/account_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 activate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def activate
            @user = User.find_by(activation_code: params[:activation_token])
        
            if @user.nil?
              session[:notice] = _("We couldn't find an account to be activated. "\
        Severity: Minor
        Found in app/controllers/public/account_controller.rb - About 1 hr to fix

          Method login has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def login
              store_location(request.referer) unless params[:return_to] || session[:return_to]
          
              return unless request.post?
          
          
          Severity: Minor
          Found in app/controllers/public/account_controller.rb - About 1 hr to fix

            Method check_redirection_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def check_redirection_options(user, condition, default, options = {})
                  if options[:signup] && (target = session.delete(:after_signup_redirect_to))
                    redirect_to target
                  else
                    case condition
            Severity: Minor
            Found in app/controllers/public/account_controller.rb - About 55 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 activate_enterprise has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def activate_enterprise
                @terms_of_use = environment.terms_of_use
                @enterprise = load_enterprise
                @question = @enterprise.question
                return unless check_answer
            Severity: Minor
            Found in app/controllers/public/account_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