django/django

View on GitHub
django/http/multipartparser.py

Summary

Maintainability
F
3 days
Test Coverage

Function parse has a Cognitive Complexity of 84 (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 505 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_header has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_header(line):
        """
        Parse the header into a key-value.
    
        Input (line): bytes, output: str for key/name, bytes for values which
    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_boundary_stream has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_boundary_stream(stream, max_header_size):
        """
        Parse one and exactly one stream that encapsulates a boundary.
        """
        # Stream at beginning of header, look for end of header
    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

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

      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

        Function __init__ has a Cognitive Complexity of 7 (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 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 _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