plataformatec/devise

View on GitHub

Showing 37 of 37 total issues

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

        Consider simplifying this complex logical expression.
        Open

                if Devise.activerecord51?
                  def postpone_email_change?
                    postpone = self.class.reconfirmable &&
                      will_save_change_to_email? &&
                      !@bypass_confirmation_postpone &&
        Severity: Critical
        Found in lib/devise/models/confirmable.rb - About 2 hrs to fix

          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 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 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 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

                  Consider simplifying this complex logical expression.
                  Open

                          if Devise.activerecord51?
                            def clear_reset_password_token?
                              encrypted_password_changed = respond_to?(:will_save_change_to_encrypted_password?) && will_save_change_to_encrypted_password?
                              authentication_keys_changed = self.class.authentication_keys.any? do |attribute|
                                respond_to?("will_save_change_to_#{attribute}?") && send("will_save_change_to_#{attribute}?")
                  Severity: Major
                  Found in lib/devise/models/recoverable.rb - About 1 hr to fix

                    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 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 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

                    Severity
                    Category
                    Status
                    Source