NovemberOscar/Sanic-JWT-Extended

View on GitHub

Showing 14 of 50 total issues

Function jwt_required has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def jwt_required(
    function=None, *, allow=None, deny=None, fresh_required=False,
):
    def real(fn):
        @wraps(fn)
Severity: Minor
Found in sanic_jwt_extended/decorators.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 create_access_token has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def create_access_token(
        cls,
        identity,
        role=None,
        fresh=None,
Severity: Minor
Found in sanic_jwt_extended/jwt_manager.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 create_refresh_token has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def create_refresh_token(
        cls,
        identity,
        role=None,
        *,
Severity: Minor
Found in sanic_jwt_extended/jwt_manager.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 refresh_jwt_required has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def refresh_jwt_required(function=None, *, allow=None, deny=None):
    def real(fn):
        @wraps(fn)
        async def wrapper(*args, **kwargs):
            request = _get_request(args)
Severity: Minor
Found in sanic_jwt_extended/decorators.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 create_access_token has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_access_token(
Severity: Major
Found in sanic_jwt_extended/jwt_manager.py - About 1 hr to fix

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

    def _get_raw_jwt_from_request(request, is_access=True):
        functions: List[jwt_get_function] = []
    
        for eligible_location in JWT.config.token_location:
            if eligible_location == "header":
    Severity: Minor
    Found in sanic_jwt_extended/decorators.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 create_refresh_token has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def create_refresh_token(
    Severity: Major
    Found in sanic_jwt_extended/jwt_manager.py - About 1 hr to fix

      Function _validate_config has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _validate_config(cls):
              if cls.config.algorithm.startswith("HS") and not cls.config.secret_key:
                  raise ConfigurationConflictError(
                      "HS* algorithm needs secret key to encode token"
                  )
      Severity: Minor
      Found in sanic_jwt_extended/jwt_manager.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 compare_digest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def compare_digest(a, b):
              if isinstance(a, str):
                  a = a.encode("utf-8")
              if isinstance(b, str):
                  b = b.encode("utf-8")
      Severity: Minor
      Found in sanic_jwt_extended/decorators.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 jwt_required has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def jwt_required(
      Severity: Minor
      Found in sanic_jwt_extended/decorators.py - About 35 mins to fix

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

            def _encode_jwt(cls, token_type, payload, expires_delta):
                algorithm = cls.config.algorithm
                secret = (
                    cls.config.secret_key
                    if algorithm.startswith("HS")
        Severity: Minor
        Found in sanic_jwt_extended/jwt_manager.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 _get_raw_jwt_from_cookies has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def _get_raw_jwt_from_cookies(request, is_access):
            cookie_key = JWT.config.jwt_cookie if is_access else JWT.config.refresh_jwt_cookie
            csrf_header_key = (
                JWT.config.jwt_csrf_header if is_access else JWT.config.refresh_jwt_csrf_header
            )
        Severity: Minor
        Found in sanic_jwt_extended/decorators.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 __post_init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def __post_init__(self):
                self.raw_data = self._decode_jwt()
        
                self.type = self._get_type()
                self.role = (
        Severity: Minor
        Found in sanic_jwt_extended/tokens.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 _setup_blacklist has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _setup_blacklist(cls):
                if cls.config.use_blacklist is True:
                    blacklist_cls = (
                        cls.config.blacklist_class
                        if cls.config.blacklist_class
        Severity: Minor
        Found in sanic_jwt_extended/jwt_manager.py - About 25 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

        Severity
        Category
        Status
        Source
        Language