xlab-si/xopera-opera

View on GitHub
src/opera/instance/node.py

Summary

Maintainability
C
1 day
Test Coverage

File node.py has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Optional
from pathlib import Path

from opera_tosca_parser.parser.tosca.v_1_3.template.node import Node as Template
from opera_tosca_parser.parser.tosca.v_1_3.template.trigger import Trigger
Severity: Minor
Found in src/opera/instance/node.py - About 4 hrs to fix

    Function get_property has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_property(self, params):
            host, prop, *rest = params
    
            if host == OperationHost.SELF.value:
                # TODO: Add support for nested property values.
    Severity: Minor
    Found in src/opera/instance/node.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 invoke_trigger has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def invoke_trigger(self, verbose: bool, workdir: str, trigger: Trigger,
                           notification_file_contents: Optional[str]):
            for interface_name, operation_name, _ in trigger.action:
                # get node's interface and interface operations that are referenced in a trigger action
                interface = self.template.interfaces.get(interface_name, None)
    Severity: Minor
    Found in src/opera/instance/node.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 notify has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def notify(self, verbose: bool, workdir: str, trigger_name_or_event: Optional[str],
                   notification_file_contents: Optional[str]):
            thread_utils.print_thread(f"  Notifying {self.tosca_id}")
    
            for policy in self.template.policies:
    Severity: Minor
    Found in src/opera/instance/node.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 notify has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def notify(self, verbose: bool, workdir: str, trigger_name_or_event: Optional[str],
    Severity: Minor
    Found in src/opera/instance/node.py - About 35 mins to fix

      Function _configure_requirements has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _configure_requirements(self,
      Severity: Minor
      Found in src/opera/instance/node.py - About 35 mins to fix

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

            def _configure_requirements(self,
                                        source_operation: ConfigureInterfaceOperation,
                                        target_operation: ConfigureInterfaceOperation,
                                        verbose: bool, workdir: str,
                                        validate: bool = False):
        Severity: Minor
        Found in src/opera/instance/node.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