django/django

View on GitHub
django/http/multipartparser.py

Summary

Maintainability
F
4 days
Test Coverage

Function _parse has a Cognitive Complexity of 99 (exceeds 5 allowed). Consider refactoring.
Open

    def _parse(self):
        """
        Parse the POST data and break it into a FILES MultiValueDict and a POST
        MultiValueDict.

Severity: Minor
Found in django/http/multipartparser.py - About 1 day 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

File multipartparser.py has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Multi-part parsing for file uploads.

Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to
file upload handlers for processing.
Severity: Major
Found in django/http/multipartparser.py - About 1 day to fix

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

    def parse_boundary_stream(stream, max_header_size):
        """
        Parse one and exactly one stream that encapsulates a boundary.
        """
    
    
    Severity: Minor
    Found in django/http/multipartparser.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 __next__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def __next__(self):
            if self._done:
                raise StopIteration()
    
            stream = self._stream
    Severity: Minor
    Found in django/http/multipartparser.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(self):
            # Call the actual parse routine and close all open files in case of
            # errors. This is needed because if exceptions are thrown the
            # MultiPartParser will not be garbage collected immediately and
            # resources would be kept alive. This is only needed for errors because
    Severity: Minor
    Found in django/http/multipartparser.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 read has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def read(self, size=None):
            def parts():
                remaining = self._remaining if size is None else size
                # do the whole thing in one shot if no limit was provided.
                if remaining is None:
    Severity: Minor
    Found in django/http/multipartparser.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

    Avoid deeply nested control flow statements.
    Open

                                    if chunk is None:
                                        # Don't continue if the chunk received by
                                        # the handler is None.
                                        break
    
    
    Severity: Major
    Found in django/http/multipartparser.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                      while remaining != 0:
                                          over_chunk = field_stream.read(4 - remaining)
                                          if not over_chunk:
                                              break
                                          stripped_chunk += b"".join(over_chunk.split())
      Severity: Major
      Found in django/http/multipartparser.py - About 45 mins to fix

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

            def __init__(self, META, input_data, upload_handlers, encoding=None):
                """
                Initialize the MultiPartParser object.
        
                :META:
        Severity: Minor
        Found in django/http/multipartparser.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

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

            def _find_boundary(self, data):
                """
                Find a multipart boundary in data.
        
                Should no boundary exist in the data, return None. Otherwise, return
        Severity: Minor
        Found in django/http/multipartparser.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