plataformatec/devise

View on GitHub

Method devise_for has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    def devise_for(*resources)
      @devise_finalized = false
      raise_no_secret_key unless Devise.secret_key
      options = resources.extract_options!

Severity: Minor
Found in lib/devise/rails/routes.rb - About 4 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

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

  class FailureApp < ActionController::Metal
    include ActionController::UrlFor
    include ActionController::Redirecting

    include Rails.application.routes.url_helpers
Severity: Minor
Found in lib/devise/failure_app.rb - About 3 hrs to fix

    File devise.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rails'
    require 'active_support/core_ext/numeric/time'
    require 'active_support/dependencies'
    require 'orm_adapter'
    require 'set'
    Severity: Minor
    Found in lib/devise.rb - About 2 hrs to fix

      Class Authenticatable has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Authenticatable < Base
            attr_accessor :authentication_hash, :authentication_type, :password
      
            def store?
              super && !mapping.to.skip_session_storage.include?(authentication_type)
      Severity: Minor
      Found in lib/devise/strategies/authenticatable.rb - About 2 hrs to fix

        Method add_module has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.add_module(module_name, options = {})
            options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
        
            ALL.insert (options[:insert_at] || -1), module_name
        
        
        Severity: Minor
        Found in lib/devise.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

        Class DeviseController has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class DeviseController < Devise.parent_controller.constantize
          include Devise::Controllers::ScopedViews
        
          if respond_to?(:helper)
            helper DeviseHelper
        Severity: Minor
        Found in app/controllers/devise_controller.rb - About 2 hrs to fix

          Method devise has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def devise(*modules)
                options = modules.extract_options!.dup
          
                selected_modules = modules.map(&:to_sym).uniq.sort_by do |s|
                  Devise::ALL.index(s) || -1  # follow Devise::ALL order
          Severity: Minor
          Found in lib/devise/models.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 valid_for_authentication? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def valid_for_authentication?
                  return super unless persisted? && lock_strategy_enabled?(:failed_attempts)
          
                  # Unlock the user if the lock is expired, no matter
                  # if the user can login or not (wrong password, etc)
          Severity: Minor
          Found in lib/devise/models/lockable.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 devise_for has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def devise_for(*resources)
                @devise_finalized = false
                raise_no_secret_key unless Devise.secret_key
                options = resources.extract_options!
          
          
          Severity: Minor
          Found in lib/devise/rails/routes.rb - About 1 hr to fix

            Method update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                self.resource = resource_class.reset_password_by_token(resource_params)
                yield resource if block_given?
            
                if resource.errors.empty?
            Severity: Minor
            Found in app/controllers/devise/passwords_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 generate_helpers! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.generate_helpers!(routes=nil)
                    routes ||= begin
                      mappings = Devise.mappings.values.map(&:used_helpers).flatten.uniq
                      Devise::URL_HELPERS.slice(*mappings)
                    end
            Severity: Minor
            Found in lib/devise/controllers/url_helpers.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 add_module has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.add_module(module_name, options = {})
                options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
            
                ALL.insert (options[:insert_at] || -1), module_name
            
            
            Severity: Minor
            Found in lib/devise.rb - About 1 hr to fix

              Method devise_omniauth_callback has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def devise_omniauth_callback(mapping, controllers) #:nodoc:
                      if mapping.fullpath =~ /:[a-zA-Z_]/
                        raise <<-ERROR
              Devise does not support scoping OmniAuth callbacks under a dynamic segment
              and you have set #{mapping.fullpath.inspect}. You can work around by passing
              Severity: Minor
              Found in lib/devise/rails/routes.rb - About 1 hr to fix

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

                  def update
                    self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
                    prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
                
                    resource_updated = update_resource(resource, account_update_params)
                Severity: Minor
                Found in app/controllers/devise/registrations_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 find_or_initialize_with_errors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                        def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
                          attributes = if attributes.respond_to? :permit!
                            attributes.slice(*required_attributes).permit!.to_h.with_indifferent_access
                          else
                            attributes.with_indifferent_access.slice(*required_attributes)
                Severity: Minor
                Found in lib/devise/models/authenticatable.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 redirect_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def redirect_url
                      if warden_message == :timeout
                        flash[:timedout] = true if is_flashing_format?
                
                        path = if request.get?
                Severity: Minor
                Found in lib/devise/failure_app.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 find_scope! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.find_scope!(obj)
                      obj = obj.devise_scope if obj.respond_to?(:devise_scope)
                      case obj
                      when String, Symbol
                        return obj.to_sym
                Severity: Minor
                Found in lib/devise/mapping.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 update_with_password has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def update_with_password(params, *options)
                        current_password = params.delete(:current_password)
                
                        if params[:password].blank?
                          params.delete(:password)
                Severity: Minor
                Found in lib/devise/models/database_authenticatable.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 failure_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def failure_message
                    exception = request.respond_to?(:get_header) ? request.get_header("omniauth.error") : request.env["omniauth.error"]
                    error   = exception.error_reason if exception.respond_to?(:error_reason)
                    error ||= exception.error        if exception.respond_to?(:error)
                    error ||= (request.respond_to?(:get_header) ? request.get_header("omniauth.error.type") : request.env["omniauth.error.type"]).to_s
                Severity: Minor
                Found in app/controllers/devise/omniauth_callbacks_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 i18n_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def i18n_message(default = nil)
                      message = warden_message || default || :unauthenticated
                
                      if message.is_a?(Symbol)
                        options = {}
                Severity: Minor
                Found in lib/devise/failure_app.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

                Severity
                Category
                Status