django/django

View on GitHub
django/contrib/auth/forms.py

Summary

Maintainability
C
1 day
Test Coverage

File forms.py has 470 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import unicodedata

from django import forms
from django.contrib.auth import authenticate, get_user_model, password_validation
from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher
Severity: Minor
Found in django/contrib/auth/forms.py - About 7 hrs to fix

    Function save has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def save(
    Severity: Major
    Found in django/contrib/auth/forms.py - About 1 hr to fix

      Function get_context has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_context(self, name, value, attrs):
              context = super().get_context(name, value, attrs)
              usable_password = value and not value.startswith(UNUSABLE_PASSWORD_PREFIX)
              summary = []
              if usable_password:
      Severity: Minor
      Found in django/contrib/auth/forms.py - 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

      Function send_mail has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def send_mail(
      Severity: Minor
      Found in django/contrib/auth/forms.py - About 45 mins to fix

        Function save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def save(
                self,
                domain_override=None,
                subject_template_name="registration/password_reset_subject.txt",
                email_template_name="registration/password_reset_email.html",
        Severity: Minor
        Found in django/contrib/auth/forms.py - 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