devise-security/devise-security

View on GitHub

Showing 10 of 212 total issues

Method included has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def self.included(base)
        base.extend ClassMethods
        assert_secure_validations_api!(base)

        base.class_eval do
Severity: Minor
Found in lib/devise-security/models/secure_validatable.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 handle_password_change has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def handle_password_change
        return if warden.nil?

        if !devise_controller? &&
           !ignore_password_expire? &&
Severity: Minor
Found in lib/devise-security/controllers/helpers.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 included has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.included(base)
        base.extend ClassMethods
        assert_secure_validations_api!(base)

        base.class_eval do
Severity: Minor
Found in lib/devise-security/models/secure_validatable.rb - About 1 hr to fix

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

      def validate_each(record, attribute, password)
        return if password.blank?
    
        options.sort.each do |pattern_name, minimum|
          normalized_option = pattern_name.to_s.singularize.to_sym
    Severity: Minor
    Found in lib/devise-security/validators/password_complexity_validator.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 apply has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def apply
            Devise::PasswordsController.send(:include, Patches::ControllerCaptcha) if Devise.captcha_for_recover || Devise.security_question_for_recover
            Devise::UnlocksController.send(:include, Patches::ControllerCaptcha) if Devise.captcha_for_unlock || Devise.security_question_for_unlock
            Devise::ConfirmationsController.send(:include, Patches::ControllerCaptcha) if Devise.captcha_for_confirmation
    
    
    Severity: Minor
    Found in lib/devise-security/patches.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_with_password has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

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

          def handle_paranoid_verification
            return if warden.nil?
    
            if !devise_controller? && !request.format.nil? && request.format.html?
              Devise.mappings.keys.flatten.any? do |scope|
    Severity: Minor
    Found in lib/devise-security/controllers/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_password_changed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_password_changed
          if defined?(will_save_change_to_attribute?)
            return unless (new_record? || will_save_change_to_encrypted_password?) && !will_save_change_to_password_changed_at?
          else
            return unless (new_record? || encrypted_password_changed?) && !password_changed_at_changed?
    Severity: Minor
    Found in lib/devise-security/models/password_expirable.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 archive_password has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def archive_password
            if max_old_passwords.positive?
              return true if old_passwords.where(encrypted_password: encrypted_password_was).exists?
    
              old_passwords.create!(encrypted_password: encrypted_password_was) if encrypted_password_was.present?
    Severity: Minor
    Found in lib/devise-security/models/password_archivable.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

    Method email_not_equal_password_validation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def email_not_equal_password_validation
            return if allow_passwords_equal_to_email
    
            return if password.blank? || email.blank? || (!new_record? && !will_save_change_to_encrypted_password?)
    
    
    Severity: Minor
    Found in lib/devise-security/models/secure_validatable.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

    Severity
    Category
    Status
    Source
    Language