idlesign/django-oauthost

View on GitHub

Showing 18 of 27 total issues

File endpoints.py has 681 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
from base64 import b64decode
from datetime import datetime
from time import time
from typing import List, Union
Severity: Major
Found in oauthost/endpoints.py - About 1 day to fix

    Function register_client has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def register_client(
            title: str,
            identifier: str,
            redirect_uri: str,
            registrant: 'User',
    Severity: Minor
    Found in oauthost/toolbox.py - About 3 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 handle has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
    
            if not len(args):
                raise CommandError('This command accepts space delimited list of application names.')
    
    
    Severity: Minor
    Found in oauthost/management/commands/syncscopes.py - About 3 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 models.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from uuid import uuid4
    from random import randrange
    
    from django.conf import settings
    from django.db import models, IntegrityError
    Severity: Minor
    Found in oauthost/models.py - About 2 hrs to fix

      Function get_client has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_client(self) -> Client:
              """Returns client object."""
              client = None
              auth_error_headers = {}
              client_id = None
      Severity: Minor
      Found in oauthost/endpoints.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 filter_scopes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def filter_scopes(self, client: Client) -> List[Scope]:
              """Gets space delimited list of scopes from client request,
              and returns a list of scope objects, corrected according
              to auth server settings.
      
      
      Severity: Minor
      Found in oauthost/endpoints.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 register_client has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def register_client(
      Severity: Major
      Found in oauthost/toolbox.py - About 1 hr to fix

        Function get_response_document has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get_response_document(
        Severity: Minor
        Found in oauthost/endpoints.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if register_unknown_scopes:
                                  scope_obj = Scope(identifier=scope, title=scope)
                                  scope_obj.save()
          
                              else:
          Severity: Major
          Found in oauthost/toolbox.py - About 45 mins to fix

            Function save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def save(self, force_insert=False, force_update=False, **kwargs):
                    if not self.code:
                        while True:
                            self.code = self.generate_code()
                            try:
            Severity: Minor
            Found in oauthost/models.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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def save(self, force_insert=False, force_update=False, **kwargs):
                    if not self.access_token:
                        while True:
                            self.access_token = self.generate_token()
                            self.refresh_token = self.generate_token()
            Severity: Minor
            Found in oauthost/models.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 validate_token has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate_token(self) -> bool:
            
                    if self._token is None:
                        return False
            
            
            Severity: Minor
            Found in oauthost/auth_handlers.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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def save(self, force_insert=False, force_update=False, **kwargs):
            
                    if not self.identifier:
            
                        while True:
            Severity: Minor
            Found in oauthost/models.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Minor
            Found in oauthost/endpoints.py - About 35 mins to fix

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

                  def handle_authorization_code(self, client: Client) -> Token:
                      """Access Token Request"""
              
                      code = self.input_params.get('code')  # REQUIRED
                      redirect_uri = self.input_params.get('redirect_uri')  # REQUIRED
              Severity: Minor
              Found in oauthost/endpoints.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 False
              Severity: Major
              Found in oauthost/auth_handlers.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return True
                Severity: Major
                Found in oauthost/auth_handlers.py - About 30 mins to fix

                  Function fetch_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def fetch_token(self):
                          token = None
                  
                          request = self._request
                  
                  
                  Severity: Minor
                  Found in oauthost/auth_handlers.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