Peter-Slump/django-keycloak

View on GitHub

Showing 13 of 35 total issues

Function get_keycloak_permissions has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def get_keycloak_permissions(self, user_obj):
        if not hasattr(user_obj, 'oidc_profile'):
            return set()

        rpt_decoded = django_keycloak.services.oidc_profile\
Severity: Minor
Found in src/django_keycloak/auth/backends.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

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

class KeycloakRemoteUser(object):
    """
    A class based on django.contrib.auth.models.User.
    See https://docs.djangoproject.com/en/2.0/ref/contrib/auth/
    #django.contrib.auth.models.User
Severity: Minor
Found in src/django_keycloak/remote_user.py - About 2 hrs to fix

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

    def remote_user_login(request, user, backend=None):
        """
        Creates a session for the user.
        Based on the login function django.contrib.auth.login but uses a slightly
        different approach since the user is not backed by a database model.
    Severity: Minor
    Found in src/django_keycloak/auth/__init__.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

    Avoid deeply nested control flow statements.
    Open

                            if '.' in p['resource_set_name']:
                                app, model = p['resource_set_name'].split('.', 1)
                                permissions.append('{app}.{scope}_{model}'.format(
                                    app=app,
                                    scope=scope,
    Severity: Major
    Found in src/django_keycloak/auth/backends.py - About 45 mins to fix

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

          def has_perm(self, perm, obj=None):
              """
              Logic from django.contrib.auth.models._user_has_perm
              :param perm:
              :param obj:
      Severity: Minor
      Found in src/django_keycloak/remote_user.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__(self, content=b'', authorization_method='Bearer',
      Severity: Minor
      Found in src/django_keycloak/response.py - About 35 mins to fix

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

            def has_module_perms(self, module):
                """
                Logic from django.contrib.auth.models._user_has_module_perms
                :param module:
                :return:
        Severity: Minor
        Found in src/django_keycloak/remote_user.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(self, *args, **kwargs):
                request = self.request
        
                if 'error' in request.GET:
                    return HttpResponseServerError(request.GET['error'])
        Severity: Minor
        Found in src/django_keycloak/views.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 synchronize_permissions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def synchronize_permissions(modeladmin, request, queryset):
            for realm in queryset:
                try:
                    django_keycloak.services.permissions.synchronize(
                        client=realm.client)
        Severity: Minor
        Found in src/django_keycloak/admin/realm.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 synchronize_resources has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def synchronize_resources(client, app_config):
            """
            Synchronize all resources (models) to the Keycloak server for given client
            and Django App.
        
        
        Severity: Minor
        Found in src/django_keycloak/services/uma.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 synchronize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def synchronize(client):
            """
            :param django_keycloak.models.Client client:
            :return:
            """
        Severity: Minor
        Found in src/django_keycloak/services/permissions.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 synchronize_resources has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def synchronize_resources(modeladmin, request, queryset):
            for realm in queryset:
                try:
                    django_keycloak.services.uma.synchronize_client(
                        client=realm.client)
        Severity: Minor
        Found in src/django_keycloak/admin/realm.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 process_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_request(self, request):
                """
                Forces authentication on all requests except the URL's configured in
                the exempt setting.
                """
        Severity: Minor
        Found in src/django_keycloak/middleware.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