kotti/views/users.py

Summary

Maintainability
D
2 days
Test Coverage

File users.py has 528 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" User management screens """
import re
from urllib.parse import urlencode

import colander
Severity: Major
Found in kotti/views/users.py - About 1 day to fix

    Function roles_form_handler has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def roles_form_handler(context, request, available_role_names, groups_lister):
        changed = []
    
        if "apply" in request.POST:
            p_to_r = {}
    Severity: Minor
    Found in kotti/views/users.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 search_principals has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def search_principals(request, context=None, ignore=None, extra=()):
        flash = request.session.flash
        principals = get_principals()
    
        if ignore is None:
    Severity: Minor
    Found in kotti/views/users.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 user_delete has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_delete(context, request):
        principals = get_principals()
    
        if "name" in request.params and request.params["name"]:
            user_or_group = request.params["name"]
    Severity: Minor
    Found in kotti/views/users.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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self):
            api = template_api(self.context, self.request, cp_links=CONTROL_PANEL_LINKS)
    
            api.page_title = _("User Management")
    
    
    Severity: Minor
    Found in kotti/views/users.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 deferred_email_validator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def deferred_email_validator(node, kw):
        def raise_invalid_email(node, value):
            raise colander.Invalid(node, _("A user with that email already exists."))
    
        request = kw["request"]
    Severity: Minor
    Found in kotti/views/users.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 share_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def share_node(context, request):
        # Allow roles_form_handler to do processing on 'apply':
        if "apply" in request.POST:
            if request.params.get("csrf_token") != request.session.get_csrf_token():
                raise HTTPBadRequest("Invalid CSRF token")
    Severity: Minor
    Found in kotti/views/users.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

    There are no issues that match your filters.

    Category
    Status