kennethreitz/requests

View on GitHub
src/requests/sessions.py

Summary

Maintainability
D
2 days
Test Coverage

File sessions.py has 566 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
requests.sessions
~~~~~~~~~~~~~~~~~

This module provides a Session object to manage and persist settings across
Severity: Major
Found in src/requests/sessions.py - About 1 day to fix

    Function resolve_redirects has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def resolve_redirects(
            self,
            resp,
            req,
            stream=False,
    Severity: Minor
    Found in src/requests/sessions.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 request has 16 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def request(
    Severity: Major
    Found in src/requests/sessions.py - About 2 hrs to fix

      Function send has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def send(self, request, **kwargs):
              """Send a given PreparedRequest.
      
              :rtype: requests.Response
              """
      Severity: Minor
      Found in src/requests/sessions.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 resolve_redirects has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def resolve_redirects(
      Severity: Major
      Found in src/requests/sessions.py - About 1 hr to fix

        Function merge_environment_settings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def merge_environment_settings(self, url, proxies, stream, verify, cert):
                """
                Check the environment and merge it with some settings.
        
                :rtype: dict
        Severity: Minor
        Found in src/requests/sessions.py - About 45 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 merge_environment_settings has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def merge_environment_settings(self, url, proxies, stream, verify, cert):
        Severity: Minor
        Found in src/requests/sessions.py - About 35 mins to fix

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

              def should_strip_auth(self, old_url, new_url):
                  """Decide whether Authorization header should be removed when redirecting"""
                  old_parsed = urlparse(old_url)
                  new_parsed = urlparse(new_url)
                  if old_parsed.hostname != new_parsed.hostname:
          Severity: Minor
          Found in src/requests/sessions.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