kennethreitz/requests

View on GitHub

Showing 66 of 66 total issues

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

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

          def content(self):
              """Content of the response, in bytes."""
      
              if self._content is False:
                  # Read the contents.
      Severity: Minor
      Found in src/requests/models.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

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

      def _implementation():
          """Return a dict with the Python implementation and version.
      
          Provide both the name and the version of the Python implementation
          currently running. For example, on CPython 3.10.3 it will return
      Severity: Minor
      Found in src/requests/help.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

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

      def extract_zipped_paths(path):
          """Replace nonexistent paths that look like they refer to a member of a zip
          archive with the location of an extracted copy of the target, or else
          just return the provided path unchanged.
          """
      Severity: Minor
      Found in src/requests/utils.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

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

      def cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True):
          """Returns a CookieJar from a key/value dictionary.
      
          :param cookie_dict: Dict of key/values to insert into CookieJar.
          :param cookiejar: (optional) A cookiejar to add the cookies to.
      Severity: Minor
      Found in src/requests/cookies.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

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

      def _init():
          for code, titles in _codes.items():
              for title in titles:
                  setattr(codes, title, code)
                  if not title.startswith(("\\", "/")):
      Severity: Minor
      Found in src/requests/status_codes.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

      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

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

          def raise_for_status(self):
              """Raises :class:`HTTPError`, if one occurred."""
      
              http_error_msg = ""
              if isinstance(self.reason, bytes):
      Severity: Minor
      Found in src/requests/models.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

      Avoid too many return statements within this function.
      Open

              return True
      Severity: Major
      Found in src/requests/utils.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return "utf-32-be"
        Severity: Major
        Found in src/requests/utils.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return "utf-16-le"
          Severity: Major
          Found in src/requests/utils.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return "utf-32-le"
            Severity: Major
            Found in src/requests/utils.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return None
              Severity: Major
              Found in src/requests/utils.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return "utf-16-be"
                Severity: Major
                Found in src/requests/utils.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return True
                  Severity: Major
                  Found in src/requests/utils.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return True
                    Severity: Major
                    Found in src/requests/utils.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return False
                      Severity: Major
                      Found in src/requests/utils.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return False
                        Severity: Major
                        Found in src/requests/utils.py - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language