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\
- Read upRead up
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
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.
- Read upRead up
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,
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:
- Read upRead up
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',
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:
- Read upRead up
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'])
- Read upRead up
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)
- Read upRead up
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.
- Read upRead up
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:
"""
- Read upRead up
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)
- Read upRead up
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.
"""
- Read upRead up
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"