r3w0p/bobocep

View on GitHub
bobocep/cep/engine/decider/decider.py

Summary

Maintainability
F
4 days
Test Coverage
A
100%

File decider.py has 512 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (c) 2019-2024 r3w0p
# The following code can be redistributed and/or
# modified under the terms of the MIT License.

"""
Severity: Major
Found in bobocep/cep/engine/decider/decider.py - About 1 day to fix

    Function on_distributed_update has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
    Open

        def on_distributed_update(
                self,
                completed: List[BoboRunSerial],
                halted: List[BoboRunSerial],
                updated: List[BoboRunSerial]) -> None:
    Severity: Minor
    Found in bobocep/cep/engine/decider/decider.py - About 1 day 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 _check_against_patterns has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_against_patterns(self, event: BoboEvent) -> \
                Tuple[List[BoboRun], List[BoboRun]]:
            """
            :param event: An event.
    
    
    Severity: Minor
    Found in bobocep/cep/engine/decider/decider.py - About 4 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 _check_against_runs has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_against_runs(self, event: BoboEvent) -> \
                Tuple[List[BoboRun], List[BoboRun], List[BoboRun]]:
            """
            :param event: An event.
    
    
    Severity: Minor
    Found in bobocep/cep/engine/decider/decider.py - About 4 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

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

    class BoboDecider(BoboEngineTask,
                      BoboDeciderPublisher,
                      BoboReceiverSubscriber,
                      BoboDistributedSubscriber):
        """
    Severity: Minor
    Found in bobocep/cep/engine/decider/decider.py - About 2 hrs to fix

      Function snapshot has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def snapshot(self) -> Tuple[
              List[BoboRunSerial], List[BoboRunSerial], List[BoboRunSerial]
          ]:
              """
              A snapshot of the current state of the Decider.
      Severity: Minor
      Found in bobocep/cep/engine/decider/decider.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

      Avoid deeply nested control flow statements.
      Open

                              if runremote.run_id != runlocal.run_id:
                                  runlocalserial = runlocal.serialize()
                                  remlist[k] = runlocalserial
      
                                  self._maybe_cache(
      Severity: Major
      Found in bobocep/cep/engine/decider/decider.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if run.is_halted():
                                    runs_to_remove.append((
                                        phenomenon_name, pattern_name, run.run_id))
                                    if run.is_complete():
                                        runs_halted_complete.append(run)
        Severity: Major
        Found in bobocep/cep/engine/decider/decider.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (
                                          (not pattern.singleton) or
                                          (pattern.singleton and len(runs) == 0)
                                  ):
                                      self._add_run(
          Severity: Major
          Found in bobocep/cep/engine/decider/decider.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if i == 0:
                                        remove_indices_completed.append(k)
                                    else:
                                        remove_indices_halted.append(k)
            
            
            Severity: Major
            Found in bobocep/cep/engine/decider/decider.py - About 45 mins to fix

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

                  def __init__(self,
              Severity: Minor
              Found in bobocep/cep/engine/decider/decider.py - About 35 mins to fix

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

                    def update(self) -> bool:
                        """
                        Performs an update cycle of the decider that takes an event from its
                        queue and checks it against phenomena and existing runs.
                
                
                Severity: Minor
                Found in bobocep/cep/engine/decider/decider.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 _maybe_cache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _maybe_cache(
                            self,
                            completed: List[BoboRunSerial],
                            halted: List[BoboRunSerial]) -> None:
                        """
                Severity: Minor
                Found in bobocep/cep/engine/decider/decider.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(self,
                                 phenomena: List[BoboPhenomenon],
                                 gen_event_id: BoboGenEventID,
                                 gen_run_id: BoboGenEventID,
                                 max_cache: int = 0,
                Severity: Minor
                Found in bobocep/cep/engine/decider/decider.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_pattern has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _get_pattern(self,
                                     phenomenon_name: str,
                                     pattern_name: str) -> Optional[BoboPattern]:
                        """
                        :param phenomenon_name: A phenomenon name.
                Severity: Minor
                Found in bobocep/cep/engine/decider/decider.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 all_runs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def all_runs(self) -> Tuple[BoboRun, ...]:
                        """
                        :return: All active runs in the decider.
                        """
                        with self._lock:
                Severity: Minor
                Found in bobocep/cep/engine/decider/decider.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