kennethreitz/requests

View on GitHub
src/requests/adapters.py

Summary

Maintainability
C
1 day
Test Coverage

File adapters.py has 488 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
requests.adapters
~~~~~~~~~~~~~~~~~

This module contains the transport adapters that Requests uses to define
Severity: Minor
Found in src/requests/adapters.py - About 7 hrs to fix

    Function cert_verify has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def cert_verify(self, conn, url, verify, cert):
            """Verify a SSL certificate. This method should not be called from user
            code, and is only exposed for use when subclassing the
            :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
    
    
    Severity: Minor
    Found in src/requests/adapters.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 send has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def send(
    Severity: Major
    Found in src/requests/adapters.py - About 50 mins to fix

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

          def send(
      Severity: Minor
      Found in src/requests/adapters.py - About 45 mins to fix

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

            def _get_connection(self, request, verify, proxies=None, cert=None):
        Severity: Minor
        Found in src/requests/adapters.py - About 35 mins to fix

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

          def _urllib3_request_context(
              request: "PreparedRequest",
              verify: "bool | str | None",
              client_cert: "typing.Tuple[str, str] | str | None",
          ) -> "(typing.Dict[str, typing.Any], typing.Dict[str, typing.Any])":
          Severity: Minor
          Found in src/requests/adapters.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