Showing 91 of 91 total issues

Avoid too many return statements within this function.
Open

        return "Cache Media Content"
Severity: Major
Found in kotti/views/cache.py - About 30 mins to fix

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

    def reset_workflow(objs=None, purge_existing=False):
        if objs is None:
            objs = DBSession.query(Content)
        for obj in objs:
            if purge_existing:
    Severity: Minor
    Found in kotti/workflow.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

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

    def get_appstruct(context, schema):
        appstruct = {}
        for field in schema.children:
            if hasattr(context, field.name):
                val = getattr(context, field.name)
    Severity: Minor
    Found in kotti/views/form.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

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

        def process_bind_param(self, value, dialect):
            if value is not None:
                value = [list(ace) for ace in value if ace != self.DEFAULT_ACE]
                for ace in value:
                    if ace[2] == ALL_PERMISSIONS:
    Severity: Minor
    Found in kotti/sqla.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

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

        def process_result_value(self, value, dialect):
            acl = super().process_result_value(value, dialect)
            if acl is not None:
                for ace in acl:
                    if ace[2] == self.ALL_PERMISSIONS_SERIALIZED:
    Severity: Minor
    Found in kotti/sqla.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

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

    def list_all():
        pkg_envs = [PackageEnvironment(location) for location in get_locations()]
        for pkg_env in pkg_envs:
            print(f"{pkg_env.pkg_name}:")
    
    
    Severity: Minor
    Found in kotti/migrate.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

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

        def __call__(self, event):
            results = []
            for event_type, handlers in self.items():
                if isinstance(event, event_type):
                    for handler in handlers:
    Severity: Minor
    Found in kotti/events.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

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

    def default_caching_policy_chooser(context, request, response):
        if request.method != "GET" or response.status_int != 200:
            return None
        elif isinstance(response, FileResponse):
            return "Cache Resource"
    Severity: Minor
    Found in kotti/views/cache.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

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

    def set_cache_headers(event):
        request, response = event.request, event.response
    
        # this can happen if a Pyramid tween will shortcut the normal tween
        # chain processing and return its own response early
    Severity: Minor
    Found in kotti/views/cache.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

    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

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

    def nodes_tree(request, context=None, permission="view"):
        item_mapping = {}
        item_to_children = defaultdict(lambda: [])
        for node in DBSession.query(Content).with_polymorphic(Content):
            item_mapping[node.id] = node
    Severity: Minor
    Found in kotti/views/util.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