django/django

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

Summary

Maintainability
C
1 day
Test Coverage

File forms.py has 382 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,
Severity: Minor
Found in django/contrib/auth/forms.py - About 5 hrs to fix

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

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

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

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

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

            def get_context(self, name, value, attrs):
                context = super().get_context(name, value, attrs)
                summary = []
                if not value or value.startswith(UNUSABLE_PASSWORD_PREFIX):
                    summary.append({'label': gettext("No password set.")})
        Severity: Minor
        Found in django/contrib/auth/forms.py - 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

        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',
                     use_https=False, token_generator=default_token_generator,
                     from_email=None, request=None, html_email_template_name=None,
        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