redmine/redmine

View on GitHub
app/controllers/account_controller.rb

Summary

Maintainability
D
3 days
Test Coverage

Method lost_password has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def lost_password
    (redirect_to(home_url); return) unless Setting.lost_password?
    if prt = (params[:token] || session[:password_recovery_token])
      @token = Token.find_token("recovery", prt.to_s)
      if @token.nil?
Severity: Minor
Found in app/controllers/account_controller.rb - About 5 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

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

class AccountController < ApplicationController
  helper :custom_fields
  include CustomFieldsHelper

  self.main_menu = false
Severity: Minor
Found in app/controllers/account_controller.rb - About 4 hrs to fix

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

    class AccountController < ApplicationController
      helper :custom_fields
      include CustomFieldsHelper
    
      self.main_menu = false
    Severity: Minor
    Found in app/controllers/account_controller.rb - About 3 hrs to fix

      Method lost_password has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def lost_password
          (redirect_to(home_url); return) unless Setting.lost_password?
          if prt = (params[:token] || session[:password_recovery_token])
            @token = Token.find_token("recovery", prt.to_s)
            if @token.nil?
      Severity: Major
      Found in app/controllers/account_controller.rb - About 2 hrs to fix

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

          def register
            (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
            if !request.post?
              session[:auth_source_registration] = nil
              @user = User.new(:language => current_language.to_s)
        Severity: Minor
        Found in app/controllers/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 register has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def register
            (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
            if !request.post?
              session[:auth_source_registration] = nil
              @user = User.new(:language => current_language.to_s)
        Severity: Minor
        Found in app/controllers/account_controller.rb - About 1 hr to fix

          Method password_authentication has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def password_authentication
              user = User.try_to_login!(params[:username], params[:password], false)
          
              if user.nil?
                invalid_credentials
          Severity: Minor
          Found in app/controllers/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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def activate
              (redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present?
              token = Token.find_token('register', params[:token].to_s)
              (redirect_to(home_url); return) unless token and !token.expired?
              user = token.user
          Severity: Minor
          Found in app/controllers/account_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

          Avoid too many return statements within this method.
          Open

                      return
          Severity: Major
          Found in app/controllers/account_controller.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return
            Severity: Major
            Found in app/controllers/account_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return
              Severity: Major
              Found in app/controllers/account_controller.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return
                Severity: Major
                Found in app/controllers/account_controller.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return
                  Severity: Major
                  Found in app/controllers/account_controller.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return
                    Severity: Major
                    Found in app/controllers/account_controller.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return
                      Severity: Major
                      Found in app/controllers/account_controller.rb - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status