kotti/events.py

Summary

Maintainability
C
1 day
Test Coverage

File events.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""This module includes a simple events system that allows users to
subscribe to specific events, and more particularly to *object events*
of specific object types.

See also: :ref:`events`.
Severity: Minor
Found in kotti/events.py - About 5 hrs to fix

    Function _set_path_for_new_parent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _set_path_for_new_parent(target, value, oldvalue, initiator):
        """Triggered whenever the Node's 'parent' attribute is set.
        """
        if value is None or value == oldvalue:
            # The parent is about to be set to 'None', so skip.
    Severity: Minor
    Found in kotti/events.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 set_owner has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_owner(event):
        """Set ``owner`` of the object that triggered the event.
    
        :param event: event that triggered this handler.
        :type event: :class:`ObjectInsert`
    Severity: Minor
    Found in kotti/events.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 _set_path_for_new_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _set_path_for_new_name(target, value, oldvalue, initiator):
        """Triggered whenever the Node's 'name' attribute is set.
    
        Is called with all kind of weird edge cases, e.g. name is 'None',
        parent is 'None' etc.
    Severity: Minor
    Found in kotti/events.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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, event):
            results = []
            for (evtype, objtype), handlers in self.items():
                if isinstance(event, evtype) and (
                    objtype is None or isinstance(event.object, objtype)
    Severity: Minor
    Found in kotti/events.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 __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

    There are no issues that match your filters.

    Category
    Status