kennethreitz/requests

View on GitHub

Showing 64 of 66 total issues

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

"""
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
Severity: Major
Found in src/requests/utils.py - About 1 day to fix

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

    """
    requests.models
    ~~~~~~~~~~~~~~~
    
    This module contains the primary objects that power Requests.
    Severity: Major
    Found in src/requests/models.py - About 1 day to fix

      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

        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

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

          """
          requests.cookies
          ~~~~~~~~~~~~~~~~
          
          Compatibility code to be able to use `http.cookiejar.CookieJar` with requests.
          Severity: Minor
          Found in src/requests/cookies.py - About 6 hrs to fix

            Function _encode_files has a Cognitive Complexity of 36 (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 src/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 35 (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 src/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 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 src/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 src/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 build_digest_header has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

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

            def super_len(o):
                total_length = None
                current_position = 0
            
                if isinstance(o, str):
            Severity: Minor
            Found in src/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 http.cookiejar.CookieJar, but exposes a dict
                interface.
            
                This is the CookieJar we create by default for requests and sessions that
            Severity: Minor
            Found in src/requests/cookies.py - About 2 hrs to fix

              Function proxy_bypass_registry has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def proxy_bypass_registry(host):
                      try:
                          import winreg
                      except ImportError:
                          return False
              Severity: Minor
              Found in src/requests/utils.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 _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 src/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

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

              def get_netrc_auth(url, raise_errors=False):
                  """Returns the Requests tuple auth for a given url from netrc."""
              
                  netrc_file = os.environ.get("NETRC")
                  if netrc_file is not None:
              Severity: Minor
              Found in src/requests/utils.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 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 guess_json_utf has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                def guess_json_utf(data):
                    """
                    :rtype: str
                    """
                    # JSON always starts with two ASCII characters, so detection is as
                Severity: Minor
                Found in src/requests/utils.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 unquote_unreserved has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def unquote_unreserved(uri):
                    """Un-escape any percent-escape sequences in a URI that are unreserved
                    characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
                
                    :rtype: str
                Severity: Minor
                Found in src/requests/utils.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

                Severity
                Category
                Status
                Source
                Language