lepture/authlib

View on GitHub

Showing 14 of 14 total issues

Function serialize_json has a Cognitive Complexity of 53 (exceeds 10 allowed). Consider refactoring.
Open

    def serialize_json(self, header_obj, payload, keys, sender_key=None):
        """Generate a JWE JSON Serialization (in fully general syntax).

        The JWE JSON Serialization represents encrypted content as a JSON
        object.  This representation is neither optimized for compactness nor
Severity: Minor
Found in authlib/jose/rfc7516/jwe.py - About 7 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 deserialize_json has a Cognitive Complexity of 50 (exceeds 10 allowed). Consider refactoring.
Open

    def deserialize_json(self, obj, key, decode=None, sender_key=None):
        """Extract JWE JSON Serialization.

        :param obj: JWE JSON Serialization as dict or str
        :param key: Private key used to decrypt payload
Severity: Minor
Found in authlib/jose/rfc7516/jwe.py - About 6 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 jwe.py has 533 lines of code (exceeds 460 allowed). Consider refactoring.
Open

from collections import OrderedDict
from copy import deepcopy

from authlib.common.encoding import (
    to_bytes, urlsafe_b64encode, json_b64encode, to_unicode
Severity: Major
Found in authlib/jose/rfc7516/jwe.py - About 3 hrs to fix

    Function create_load_key has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
    Open

    def create_load_key(key):
        def load_key(header, payload):
            if isinstance(key, KeySet):
                return key.find_by_kid(header.get('kid'))
    
    
    Severity: Minor
    Found in authlib/jose/rfc7519/jwt.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 deserialize_json has 37 lines of code (exceeds 35 allowed). Consider refactoring.
    Open

        def deserialize_json(self, obj, key, decode=None, sender_key=None):
            """Extract JWE JSON Serialization.
    
            :param obj: JWE JSON Serialization as dict or str
            :param key: Private key used to decrypt payload
    Severity: Minor
    Found in authlib/jose/rfc7516/jwe.py - About 1 hr to fix

      Function get_claims_options has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
      Open

          def get_claims_options(self):
              metadata = self.get_server_metadata()
              if not metadata:
                  return {}
      
      
      Severity: Minor
      Found in authlib/oauth2/rfc7592/endpoint.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 get_claims_options has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
      Open

          def get_claims_options(self):
              """Generate claims options validation from Authorization Server metadata."""
              metadata = self.get_server_metadata()
              if not metadata:
                  return {}
      Severity: Minor
      Found in authlib/oauth2/rfc7591/endpoint.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 import_key has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
      Open

          def import_key(cls, raw, options=None):
              if isinstance(raw, cls):
                  if options is not None:
                      raw.options.update(options)
                  return raw
      Severity: Minor
      Found in authlib/jose/rfc7517/asymmetric_key.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 find_encode_key has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
      Open

      def find_encode_key(key, header):
          if isinstance(key, KeySet):
              kid = header.get('kid')
              if kid:
                  return key.find_by_kid(kid)
      Severity: Minor
      Found in authlib/jose/rfc7519/jwt.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 deserialize_compact has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
      Open

          def deserialize_compact(self, s, key, decode=None, sender_key=None):
              """Extract JWE Compact Serialization.
      
              :param s: JWE Compact Serialization as bytes
              :param key: Private key used to decrypt payload
      Severity: Minor
      Found in authlib/jose/rfc7516/jwe.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 serialize_compact has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
      Open

          def serialize_compact(self, protected, payload, key, sender_key=None):
              """Generate a JWE Compact Serialization.
      
              The JWE Compact Serialization represents encrypted content as a compact,
              URL-safe string. This string is::
      Severity: Minor
      Found in authlib/jose/rfc7516/jwe.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 check_key_op has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
      Open

          def check_key_op(self, operation):
              """Check if the given key_op is supported by this key.
      
              :param operation: key operation value, such as "sign", "encrypt".
              :raise: ValueError
      Severity: Minor
      Found in authlib/jose/rfc7517/base_key.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 load_pem_private_key(raw, password=password, backend=default_backend())
      Severity: Major
      Found in authlib/jose/rfc7517/_cryptography_key.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return load_pem_public_key(raw, backend=default_backend())
        Severity: Major
        Found in authlib/jose/rfc7517/_cryptography_key.py - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language