gbrltv/CDESF2

View on GitHub

Showing 23 of 23 total issues

Function generate_clusters has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_clusters(self) -> Tuple[List[List], List[List]]:
        """
        Perform DBSCAN to create the final micro-clusters
        Works by grouping dense enough p_micro_clusters (weight >= mu)
        with distance <= 2 * self._epsilon
Severity: Minor
Found in cdesf/clustering/denstream.py - About 6 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 calculate_case_distances has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

def calculate_case_distances(
    graph: nx.DiGraph, case: Case, *, additional_attributes: "list[str]" = []
) -> "dict[str, float]":
    """
    Extracts the distances between the current graph and a given case across trace,
Severity: Minor
Found in cdesf/utils/distances.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

File cdesf.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import multiprocessing as mp
from typing import Union
from os import makedirs
from datetime import datetime
import networkx as nx
Severity: Minor
Found in cdesf/core/cdesf.py - About 4 hrs to fix

    File denstream.py has 311 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import math
    import numpy as np
    from collections import deque
    from scipy.spatial import distance
    from typing import Tuple, List
    Severity: Minor
    Found in cdesf/clustering/denstream.py - About 3 hrs to fix

      Function initialize_graph has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def initialize_graph(
          case_list: "list[Case]", additional_attributes: "list[str]" = []
      ) -> nx.DiGraph:
          """
          Initialize a graph based on the weights and time differences from a list of cases
      Severity: Minor
      Found in cdesf/utils/graph_operations.py - About 2 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 process_event has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_event(self, event):
              case_id = event["case:concept:name"]
              case_index = self.set_case(case_id, event)
              case = self.cases[case_index]
      
      
      Severity: Minor
      Found in cdesf/core/cdesf.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 initialize_cdesf has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize_cdesf(self) -> None:
              """
              Initializes system variables, creates the first Process Model Graph and initializes DenStream.
              Initializes graphics and metrics functions.
              """
      Severity: Minor
      Found in cdesf/core/cdesf.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 train has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def train(self, case: Case):
              """
              "Trains" Denstream by updating micro_clusters with a new point
      
              Parameters
      Severity: Minor
      Found in cdesf/clustering/denstream.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 merge_graphs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def merge_graphs(
          process_model_graph: nx.DiGraph, check_point_graph: nx.DiGraph
      ) -> nx.DiGraph:
          """
          Receives two graphs and merge them.
      Severity: Minor
      Found in cdesf/utils/graph_operations.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 dbscan has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def dbscan(self, buffer: List) -> None:
              """
              Performs DBSCAN to create initial p-micro-clusters
              Works by grouping points with distance <= self._epsilon
              and filtering groups that are dense enough (weight >= beta * mu)
      Severity: Minor
      Found in cdesf/clustering/denstream.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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in cdesf/core/cdesf.py - About 1 hr to fix

        Function add_point has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_point(self, case: Case) -> int:
                """
                Tries to add a point to an existing p-micro-cluster at time "t"
                Otherwise, tries to add that point to an existing o-micro-clusters
                If all fails, creates a new o-micro-cluster with that new point
        Severity: Minor
        Found in cdesf/clustering/denstream.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 feature_space has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def feature_space(process_name: str,
        Severity: Major
        Found in cdesf/visualization/feature_space.py - About 1 hr to fix

          Function feature_space has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def feature_space(process_name: str,
                            event_index: int,
                            cp: int,
                            normals: np.array,
                            outliers: np.array,
          Severity: Minor
          Found in cdesf/visualization/feature_space.py - About 55 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 deeply nested control flow statements.
          Open

                                  if to_add:
                                      connected_clusters[testing_group].append(r_cluster)
                                      change = True
                                  else:
                                      buffer_.append(r_cluster)
          Severity: Major
          Found in cdesf/clustering/denstream.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    for cluster in connected_clusters[testing_group]:
                                        dist = self.euclidean_distance(cluster.centroid,
                                                                       r_cluster.centroid)
                                        if dist <= 2 * self.epsilon:
                                            to_add = True
            Severity: Major
            Found in cdesf/clustering/denstream.py - About 45 mins to fix

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

                  def __init__(self, lambda_: float, beta: float, epsilon: float, mu: int, stream_speed: int, n_features: int):
              Severity: Minor
              Found in cdesf/clustering/denstream.py - About 45 mins to fix

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

                    def __init__(self, id_: int, centroid: np.ndarray, radius: float, weight: float, case_ids: list):
                Severity: Minor
                Found in cdesf/data_structures/cluster.py - About 35 mins to fix

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

                      def compute_cluster_metrics_helper(
                  Severity: Minor
                  Found in cdesf/utils/metrics.py - About 35 mins to fix

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

                        def compute_case_metrics(
                    Severity: Minor
                    Found in cdesf/utils/metrics.py - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language