xlab-si/xopera-opera

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

Summary

Maintainability
C
1 day
Test Coverage

Function join has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def join(self, params, node=None):
        if 1 <= len(params) <= 2:
            if not isinstance(params[0], list):
                raise DataError(f"Concat or join intrinsic function parameters '{params}' should be a list")

Severity: Minor
Found in src/opera/instance/topology.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

Topology has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class Topology:  # pylint: disable=too-many-public-methods
    def __init__(self, template, storage=None):
        self.storage = storage
        self.nodes = {n.tosca_id: n for n in (Node.instantiate(node, self) for node in template.nodes.values())}
        self.relationships = {r.tosca_id: r for r in (Relationship.instantiate(relationship, self)
Severity: Minor
Found in src/opera/instance/topology.py - About 2 hrs to fix

    Function token has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def token(params):
            if isinstance(params, list) and len(params) == 3:
                string_with_tokens = params[0]
                string_of_token_chars = params[1]
                substring_index = params[2]
    Severity: Minor
    Found in src/opera/instance/topology.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/topology.py - About 35 mins to fix

      Function deploy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def deploy(self, verbose, workdir, num_workers=None):
              # Currently, we are running a really stupid O(n^3) algorithm, but unless we get to the templates with
              # millions of node instances, we should be fine.
              with NodeExecutor(num_workers) as executor:
                  do_deploy = True
      Severity: Minor
      Found in src/opera/instance/topology.py - About 35 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 validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(self, verbose, workdir, num_workers=None):
              # Currently, we are running a really stupid O(n^3) algorithm, but unless we get to the templates with
              # millions of node instances, we should be fine.
              with NodeExecutor(num_workers) as executor:
                  do_validate = True
      Severity: Minor
      Found in src/opera/instance/topology.py - About 35 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 undeploy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def undeploy(self, verbose, workdir, num_workers=None):
              # Currently, we are running a really stupid O(n^3) algorithm, but unless we get to the templates with
              # millions of node instances, we should be fine.
              with NodeExecutor(num_workers) as executor:
                  do_undeploy = True
      Severity: Minor
      Found in src/opera/instance/topology.py - About 35 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

      Avoid too many return statements within this function.
      Open

              return "unknown"
      Severity: Major
      Found in src/opera/instance/topology.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return "error"
        Severity: Major
        Found in src/opera/instance/topology.py - About 30 mins to fix

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

              def notify(self, verbose: bool, workdir: str, trigger_name_or_event: Optional[str],
                         notification_file_contents: Optional[str], num_workers=1):
                  # This will run selected interface operations on triggers from policies that have been applied to nodes.
                  with NodeExecutor(num_workers) as executor:
                      do_notify = True
          Severity: Minor
          Found in src/opera/instance/topology.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 find_node_or_relationship has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def find_node_or_relationship(self, entity_name):
                  node = self.find_node(entity_name)
                  relationship = self.find_relationship(entity_name)
          
                  if not node and not relationship:
          Severity: Minor
          Found in src/opera/instance/topology.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