netdata/netdata

View on GitHub
src/collectors/python.d.plugin/python_modules/urllib3/response.py

Summary

Maintainability
D
2 days
Test Coverage

File response.py has 452 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: MIT
from __future__ import absolute_import
from contextlib import contextmanager
import zlib
import io
Severity: Minor
Found in src/collectors/python.d.plugin/python_modules/urllib3/response.py - About 6 hrs to fix

    HTTPResponse has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class HTTPResponse(io.IOBase):
        """
        HTTP Response container.
    
        Backwards-compatible to httplib's HTTPResponse but the response ``body`` is
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/urllib3/response.py - About 3 hrs to fix

      Function read_chunked has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def read_chunked(self, amt=None, decode_content=None):
              """
              Similar to :meth:`HTTPResponse.read`, but with an additional
              parameter: ``decode_content``.
      
      
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/urllib3/response.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 14 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, body='', headers=None, status=0, version=0, reason=None,
      Severity: Major
      Found in src/collectors/python.d.plugin/python_modules/urllib3/response.py - About 1 hr to fix

        Function read has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def read(self, amt=None, decode_content=None, cache_content=False):
                """
                Similar to :meth:`httplib.HTTPResponse.read`, but with two additional
                parameters: ``decode_content`` and ``cache_content``.
        
        
        Severity: Minor
        Found in src/collectors/python.d.plugin/python_modules/urllib3/response.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_length has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def _init_length(self, request_method):
                """
                Set initial length value for Response content if available.
                """
                length = self.headers.get('content-length')
        Severity: Minor
        Found in src/collectors/python.d.plugin/python_modules/urllib3/response.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 _error_catcher has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _error_catcher(self):
                """
                Catch low-level python exceptions, instead re-raising urllib3
                variants, so that low-level exceptions are not leaked in the
                high-level api.
        Severity: Minor
        Found in src/collectors/python.d.plugin/python_modules/urllib3/response.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 stream has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def stream(self, amt=2**16, decode_content=None):
                """
                A generator wrapper for the read() method. A call will block until
                ``amt`` bytes have been read from the connection or until the
                connection is closed.
        Severity: Minor
        Found in src/collectors/python.d.plugin/python_modules/urllib3/response.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, body='', headers=None, status=0, version=0, reason=None,
                         strict=0, preload_content=True, decode_content=True,
                         original_response=None, pool=None, connection=None,
                         retries=None, enforce_content_length=False, request_method=None):
        
        
        Severity: Minor
        Found in src/collectors/python.d.plugin/python_modules/urllib3/response.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