django/django

View on GitHub
django/forms/forms.py

Summary

Maintainability
D
2 days
Test Coverage

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

"""
Form classes
"""

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

    Function _html_output has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
            "Output HTML. Used by as_table(), as_ul(), as_p()."
            top_errors = self.non_field_errors()  # Errors that should be displayed above all fields.
            output, hidden_fields = [], []
    
    
    Severity: Minor
    Found in django/forms/forms.py - 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

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

    class BaseForm:
        """
        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', prefix=None,
                       initial=None, error_class=ErrorList, label_suffix=None,
                       empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None):
              self.is_bound = data is not None or files is not None
              self.data = MultiValueDict() if data is None else data
      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 __new__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def __new__(mcs, name, bases, attrs):
              # Collect fields from current class.
              current_fields = []
              for key, value in list(attrs.items()):
                  if isinstance(value, Field):
      Severity: Minor
      Found in django/forms/forms.py - 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

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

          def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
      Severity: Major
      Found in django/forms/forms.py - About 1 hr to fix

        Function _clean_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _clean_fields(self):
                for name, field in self.fields.items():
                    # value_from_datadict() gets the data from the data dictionaries.
                    # Each widget type knows how to retrieve its own data, because some
                    # widgets split data over several HTML fields.
        Severity: Minor
        Found in django/forms/forms.py - 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

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

            def changed_data(self):
                data = []
                for name, field in self.fields.items():
                    prefixed_name = self.add_prefix(name)
                    data_value = field.widget.value_from_datadict(self.data, self.files, prefixed_name)
        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 _html_output has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):
        Severity: Minor
        Found in django/forms/forms.py - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status