django/django

View on GitHub
django/core/serializers/xml_serializer.py

Summary

Maintainability
D
2 days
Test Coverage

File xml_serializer.py has 398 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
XML serializer.
"""

import json
Severity: Minor
Found in django/core/serializers/xml_serializer.py - About 5 hrs to fix

    Function _handle_object has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def _handle_object(self, node):
            """Convert an <object> node to a DeserializedObject."""
            # Look up the model using the model loading mechanism. If this fails,
            # bail.
            Model = self._get_model_from_node(node, "model")
    Severity: Minor
    Found in django/core/serializers/xml_serializer.py - About 3 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 _handle_fk_field_node has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def _handle_fk_field_node(self, node, field):
            """
            Handle a <field> node for a ForeignKey
            """
            # Check if there is a child node named 'None', returning None if so.
    Severity: Minor
    Found in django/core/serializers/xml_serializer.py - About 3 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 _handle_m2m_field_node has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _handle_m2m_field_node(self, node, field):
            """
            Handle a <field> node for a ManyToManyField.
            """
            model = field.remote_field.model
    Severity: Minor
    Found in django/core/serializers/xml_serializer.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 handle_m2m_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_m2m_field(self, obj, field):
            """
            Handle a ManyToManyField. Related objects are only serialized as
            references to the object's PK (i.e. the related *data* is not dumped,
            just the relation).
    Severity: Minor
    Found in django/core/serializers/xml_serializer.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 handle_fk_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_fk_field(self, obj, field):
            """
            Handle a ForeignKey (they need to be treated slightly
            differently from regular fields).
            """
    Severity: Minor
    Found in django/core/serializers/xml_serializer.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 entity_decl has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def entity_decl(
    Severity: Major
    Found in django/core/serializers/xml_serializer.py - About 50 mins to fix

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

          def __init__(self, name, value, base, sysid, pubid, notation_name):
      Severity: Minor
      Found in django/core/serializers/xml_serializer.py - About 45 mins to fix

        Function unparsed_entity_decl has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def unparsed_entity_decl(self, name, base, sysid, pubid, notation_name):
        Severity: Minor
        Found in django/core/serializers/xml_serializer.py - About 35 mins to fix

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

              def __init__(
          Severity: Minor
          Found in django/core/serializers/xml_serializer.py - About 35 mins to fix

            Function getInnerText has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            def getInnerText(node):
                """Get all the inner text of a DOM node (recursively)."""
                # inspired by https://mail.python.org/pipermail/xml-sig/2005-March/011022.html
                inner_text = []
                for child in node.childNodes:
            Severity: Minor
            Found in django/core/serializers/xml_serializer.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

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

                def handle_field(self, obj, field):
                    """
                    Handle each field on an object (except for ForeignKeys and
                    ManyToManyFields).
                    """
            Severity: Minor
            Found in django/core/serializers/xml_serializer.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