django/django

View on GitHub
django/forms/forms.py

Summary

Maintainability
D
1 day
Test Coverage

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

"""
Form classes
"""

import copy
Severity: Minor
Found in django/forms/forms.py - About 4 hrs to fix

    BaseForm has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseForm(RenderableFormMixin):
        """
        The main implementation of all the Form logic. Note that this class is
        different than Form. See the comments by the Form class for more info. Any
        improvements to the form API should be made to this class, not to the Form
    Severity: Minor
    Found in django/forms/forms.py - About 3 hrs to fix

      Function add_error has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_error(self, field, error):
              """
              Update the content of `self._errors`.
      
              The `field` argument is the name of the field to which the errors
      Severity: Minor
      Found in django/forms/forms.py - 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

      Function __init__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(
              self,
              data=None,
              files=None,
              auto_id="id_%s",
      Severity: Minor
      Found in django/forms/forms.py - 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

      Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

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

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

            def __new__(mcs, name, bases, attrs):
                # Collect fields from current class and remove them from attrs.
                attrs["declared_fields"] = {
                    key: attrs.pop(key)
                    for key, value in list(attrs.items())
        Severity: Minor
        Found in django/forms/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 get_context has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_context(self):
                fields = []
                hidden_fields = []
                top_errors = self.non_field_errors().copy()
                for name, bf in self._bound_items():
        Severity: Minor
        Found in django/forms/forms.py - 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

        There are no issues that match your filters.

        Category
        Status