kennethreitz/requests

View on GitHub

Showing 64 of 66 total issues

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 _find has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _find(self, name, domain=None, path=None):
        """Requests uses this method internally to get cookie values.

        If there are conflicting cookies, _find arbitrarily chooses one.
        See _find_no_duplicates if you want an exception thrown if there are
Severity: Minor
Found in src/requests/cookies.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 prepare has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

    Function json has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def json(self, **kwargs):
            r"""Returns the json-encoded content of a response, if any.
    
            :param \*\*kwargs: Optional arguments that ``json.loads`` takes.
            :raises requests.exceptions.JSONDecodeError: If the response body does not
    Severity: Minor
    Found in src/requests/models.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__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

      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 iter_lines has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def iter_lines(
                self, chunk_size=ITER_CHUNK_SIZE, decode_unicode=False, delimiter=None
            ):
                """Iterates over the response data, one line at a time.  When
                stream=True is set on the request, this avoids reading the
        Severity: Minor
        Found in src/requests/models.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 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 build_digest_header has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def build_digest_header(self, method, url):
                """
                :rtype: str
                """
        
        
        Severity: Minor
        Found in src/requests/auth.py - About 1 hr to fix

          Function dispatch_hook has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def dispatch_hook(key, hooks, hook_data, **kwargs):
              """Dispatches a hook dictionary on a given piece of data."""
              hooks = hooks or {}
              hooks = hooks.get(key)
              if hooks:
          Severity: Minor
          Found in src/requests/hooks.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 is_valid_cidr has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def is_valid_cidr(string_network):
              """
              Very simple check of the cidr format in no_proxy variable.
          
              :rtype: bool
          Severity: Minor
          Found in src/requests/utils.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 parse_header_links has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def parse_header_links(value):
              """Return a list of parsed link headers proxies.
          
              i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"
          
          
          Severity: Minor
          Found in src/requests/utils.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 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

            Avoid deeply nested control flow statements.
            Open

                                    if toReturn is not None:
                                        # if there are multiple cookies that meet passed in criteria
                                        raise CookieConflictError(
                                            f"There are multiple cookies with name, {name!r}"
                                        )
            Severity: Major
            Found in src/requests/cookies.py - About 45 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 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 remove_cookie_by_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def remove_cookie_by_name(cookiejar, name, domain=None, path=None):
                    """Unsets a cookie by name, by default over all domains and paths.
                
                    Wraps CookieJar.clear(), is O(n).
                    """
                Severity: Minor
                Found in src/requests/cookies.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_cookies has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def merge_cookies(cookiejar, cookies):
                    """Add cookies to cookiejar and returns a merged CookieJar.
                
                    :param cookiejar: CookieJar object to add the cookies to.
                    :param cookies: Dictionary or CookieJar object to be added.
                Severity: Minor
                Found in src/requests/cookies.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

                Avoid deeply nested control flow statements.
                Open

                                    if address_in_network(parsed.hostname, proxy_ip):
                                        return True
                                elif parsed.hostname == proxy_ip:
                Severity: Major
                Found in src/requests/utils.py - About 45 mins to fix

                  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
                    Severity
                    Category
                    Status
                    Source
                    Language