kennethreitz/requests

View on GitHub

Showing 84 of 84 total issues

File utils.py has 692 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""
requests.utils
~~~~~~~~~~~~~~
Severity: Major
Found in requests/utils.py - About 1 day to fix

    File models.py has 658 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    """
    requests.models
    ~~~~~~~~~~~~~~~
    Severity: Major
    Found in requests/models.py - About 1 day to fix

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

      # -*- coding: utf-8 -*-
      
      """
      requests.sessions
      ~~~~~~~~~~~~~~~~~
      Severity: Major
      Found in requests/sessions.py - About 1 day to fix

        File cookies.py has 427 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        
        """
        requests.cookies
        ~~~~~~~~~~~~~~~~
        Severity: Minor
        Found in requests/cookies.py - About 6 hrs to fix

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

              def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):
                  """Sends PreparedRequest object. Returns Response object.
          
                  :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
                  :param stream: (optional) Whether to stream the request content.
          Severity: Minor
          Found in requests/adapters.py - About 5 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

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

          # -*- coding: utf-8 -*-
          
          """
          requests.adapters
          ~~~~~~~~~~~~~~~~~
          Severity: Minor
          Found in requests/adapters.py - About 5 hrs to fix

            Function _encode_files has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
            Open

                def _encode_files(files, data):
                    """Build the body for a multipart/form-data request.
            
                    Will successfully encode files when passed as a dict or a list of
                    tuples. Order is retained if data is a list of tuples but arbitrary
            Severity: Minor
            Found in requests/models.py - About 5 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 prepare_body has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                def prepare_body(self, data, files, json=None):
                    """Prepares the given HTTP body data."""
            
                    # Check if file, fo, generator, iterator.
                    # If not, run through normal process.
            Severity: Minor
            Found in requests/models.py - About 4 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 prepare_url has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

                def prepare_url(self, url, params):
                    """Prepares the given HTTP URL."""
                    #: Accept objects that have string representations.
                    #: We're unable to blindly call unicode/str functions
                    #: as this will include the bytestring indicator (b'')
            Severity: Minor
            Found in requests/models.py - About 4 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 build_digest_header has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                def build_digest_header(self, method, url):
                    """
                    :rtype: str
                    """
            
            
            Severity: Minor
            Found in requests/auth.py - About 4 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 should_bypass_proxies has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

            def should_bypass_proxies(url, no_proxy):
                """
                Returns whether we should bypass proxies or not.
            
                :rtype: bool
            Severity: Minor
            Found in requests/utils.py - About 4 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 _encode_params has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

                def _encode_params(data):
                    """Encode parameters in a piece of data.
            
                    Will successfully encode parameters when passed as a dict or a list of
                    2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
            Severity: Minor
            Found in requests/models.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 resolve_redirects has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                def resolve_redirects(self, resp, req, stream=False, timeout=None,
                                      verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
                    """Receives a Response. Returns a generator of Responses or Requests."""
            
                    hist = []  # keep track of history
            Severity: Minor
            Found in 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 iter_content has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

                def iter_content(self, chunk_size=1, decode_unicode=False):
                    """Iterates over the response data.  When stream=True is set on the
                    request, this avoids reading the content at once into memory for
                    large responses.  The chunk size is the number of bytes it should
                    read into memory.  This is not necessarily the length of each item
            Severity: Minor
            Found in requests/models.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 super_len has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            def super_len(o):
                total_length = None
                current_position = 0
            
                if hasattr(o, '__len__'):
            Severity: Minor
            Found in requests/utils.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 cert_verify has a Cognitive Complexity of 22 (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 requests/adapters.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 proxy_bypass_registry has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                def proxy_bypass_registry(host):
                    try:
                        if is_py3:
                            import winreg
                        else:
            Severity: Minor
            Found in requests/utils.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

            RequestsCookieJar has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class RequestsCookieJar(cookielib.CookieJar, MutableMapping):
                """Compatibility class; is a cookielib.CookieJar, but exposes a dict
                interface.
            
                This is the CookieJar we create by default for requests and sessions that
            Severity: Minor
            Found in requests/cookies.py - About 2 hrs to fix

              Response has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Response(object):
                  """The :class:`Response <Response>` object, which contains a
                  server's response to an HTTP request.
                  """
              
              
              Severity: Minor
              Found in requests/models.py - About 2 hrs to fix

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

                    def _find_no_duplicates(self, name, domain=None, path=None):
                        """Both ``__get_item__`` and ``get`` call this function: it's never
                        used elsewhere in Requests.
                
                        :param name: a string containing name of cookie
                Severity: Minor
                Found in requests/cookies.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

                Severity
                Category
                Status
                Source
                Language