jmwri/simplejwt

View on GitHub

Showing 7 of 7 total issues

File jwt.py has 412 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Union, Callable, Tuple
import json
import hmac
import hashlib
from datetime import datetime
Severity: Minor
Found in simplejwt/jwt.py - About 5 hrs to fix

    Jwt has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Jwt:
        """
        A self-contained class that can manage encoding and decoding tokens.
        """
    
    
    Severity: Minor
    Found in simplejwt/jwt.py - About 2 hrs to fix

      Function __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, secret: Union[str, bytes], payload: dict = None,
      Severity: Major
      Found in simplejwt/jwt.py - About 1 hr to fix

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

            def compare(self, jwt: 'Jwt', compare_dates: bool = False) -> bool:
                """
                Compare against another `Jwt`.
        
                :param jwt: The token to compare against.
        Severity: Minor
        Found in simplejwt/jwt.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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, secret: Union[str, bytes], payload: dict = None,
                         alg: str = default_alg, header: dict = None,
                         issuer: str = None, subject: str = None, audience: str = None,
                         valid_to: int = None, valid_from: int = None,
                         issued_at: int = None, id: str = None):
        Severity: Minor
        Found in simplejwt/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

        Avoid too many return statements within this function.
        Open

                    return False
        Severity: Major
        Found in simplejwt/jwt.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return True
          Severity: Major
          Found in simplejwt/jwt.py - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language