whylabs/whylogs-python

View on GitHub

Showing 236 of 3,906 total issues

Function _segmented_performance_metrics has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def _segmented_performance_metrics(
    log_full_data: bool,
    schema: DatasetSchema,
    data: pd.DataFrame,
    performance_column_mapping: Dict[str, Optional[str]],
Severity: Minor
Found in python/whylogs/api/logger/__init__.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(
        self,
        svd_class: Optional[type] = None,  # TODO: maybe make this updatable: bool = False
        svd_config: Optional[SvdMetricConfig] = None,
        svd_state: Optional[MetricMessage] = None,
Severity: Minor
Found in python/whylogs/experimental/extras/nlp_metric.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 segment_processing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def segment_processing(
    schema: DatasetSchema,
    obj: Any = None,
    pandas: Optional[pd.DataFrame] = None,
    row: Optional[Dict[str, Any]] = None,
Severity: Minor
Found in python/whylogs/api/logger/segment_processing.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

Avoid deeply nested control flow statements.
Open

                        if isinstance(arr, pd.Series):
                            first = welford_online_variance_m2(existing=first, new_value=arr.iloc[0])
                        else:
                            first = welford_online_variance_m2(existing=first, new_value=arr[0])

Severity: Major
Found in python/whylogs/core/metrics/metrics.py - About 45 mins to fix

    Function column_is_nullable_datatype has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def column_is_nullable_datatype(column_name: str, datatype: str) -> MetricConstraint:
        """Check if column contains only records of specific datatype.
        Datatypes can be: integral, fractional, boolean, string, object.
    
        Returns True if there is at least one record of type datatype and there is no records of remaining types.
    Severity: Minor
    Found in python/whylogs/core/constraints/factories/types_metrics.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

    Avoid deeply nested control flow statements.
    Open

                            if validate_with_row_id:
                                action(self.name, cond_name, x, identity_list[index])  # type: ignore
                            else:
                                action(self.name, cond_name, x)  # type: ignore
    
    
    Severity: Major
    Found in python/whylogs/core/validators/condition_validator.py - About 45 mins to fix

      Function relation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def relation(op: Relation, value: Union[str, int, float]) -> Callable[[Any], bool]:  # type: ignore
          if op == Relation.match:  # type: ignore
              return lambda x: re.compile(value).match(x)  # type: ignore
          if op == Relation.fullmatch:  # type: ignore
              return lambda x: re.compile(value).fullmatch(x)  # type: ignore
      Severity: Minor
      Found in python/whylogs/core/metrics/condition_count_metric.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

      Consider simplifying this complex logical expression.
      Open

                  if col_name == name or (col_name is None and isinstance(why_type, col_type)):  # type: ignore
                      for spec in resolver_spec.metrics:
                          cfg = spec.config or self._default_config or config or MetricConfig()
                          if self._allowed_metric(name, why_type, cfg, spec.metric):
                              if spec.metric.get_namespace() in result:
      Severity: Major
      Found in python/whylogs/core/resolvers.py - About 40 mins to fix

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

            def merge(self, other: "EmbeddingMetric") -> "EmbeddingMetric":
                if self.references.value.shape != other.references.value.shape:
                    if other.references.value.shape == (1, 1):
                        # TODO: handle merging with other.serialize_references==False better
                        # The (1, 1) shape indicates the other metric was created without a reference matrix.
        Severity: Minor
        Found in python/whylogs/experimental/extras/embedding_metric.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, schedule: Schedule, fn: Callable[[], Any], timer_class: Type[Any] = Timer) -> None:
                self._logger = logging.getLogger(f"{type(self).__name__}_{id(self)}")
                self._fn = fn
                self._schedule = schedule
                self._running = True
        Severity: Minor
        Found in python/whylogs/api/logger/experimental/logger/actor/time_util.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

        Method merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          public DatasetProfileView merge(DatasetProfileView otherView) {
            if (otherView == null) {
              return this;
            }
        
        
        Severity: Minor
        Found in java/core/src/main/java/com/whylogs/core/views/DatasetProfileView.java - 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 calculate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def calculate(
                self, target_column_view: ColumnProfileView, reference_column_view: ColumnProfileView, with_thresholds=False
            ) -> Optional[DriftAlgorithmScore]:
                """Calculates drift score for a given column.
        
        
        Severity: Minor
        Found in python/whylogs/viz/drift/column_drift_algorithms.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 _write_segmented_result_set has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _write_segmented_result_set(self, file: SegmentedResultSet, **kwargs: Any) -> Tuple[bool, str]:
                views = file.get_writables()
                if not views:
                    logger.warning("Attempt to write a result set with no writables, nothing written!")
                    return True, ""
        Severity: Minor
        Found in python/whylogs/api/writer/whylabs_transaction_writer.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 __post_init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def __post_init__(self):
                if self.column_name and self.column_type:
                    logger.warning(f"ResolverSpec: column {self.column_name} also specified type, name takes precedence")
                if not (self.column_name or self.column_type):
                    raise ValueError("ResolverSpec: resolver specification must supply name or type")
        Severity: Minor
        Found in python/whylogs/core/resolvers.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 calculate_drift_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def calculate_drift_values(
            target_view: DatasetProfileView, reference_view: DatasetProfileView, statistic=False
        ) -> Dict[str, Optional[Union[ColumnDriftValue, ColumnDriftStatistic]]]:
            """Calculate drift values between both profiles. Applicable for numerical and categorical features.
        
        
        Severity: Minor
        Found in python/whylogs/viz/utils/drift_calculations.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

        Method doTrack has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          private void doTrack(HashMap<String, ?> row) {
            boolean dirty = this.schema.resolve(row);
            if (dirty) {
              Set<String> schemaColumnNames = this.schema.getColNames();
              Set<String> newColumnNames = new HashSet<>();
        Severity: Minor
        Found in java/core/src/main/java/com/whylogs/core/DatasetProfile.java - 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 whylogs_pandas_segmented_profiler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def whylogs_pandas_segmented_profiler(
            pdf_iterator: Iterable[pd.DataFrame], schema: Optional[DatasetSchema] = None
        ) -> Iterable[pd.DataFrame]:
            if schema is None or not schema.segments:
                raise ValueError(
        Severity: Minor
        Found in python/whylogs/api/pyspark/experimental/segmented_profiler.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

        Method merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          public ColumnProfileView merge(ColumnProfileView otherView) {
            if (otherView == null) {
              // TODO: log warning that otehrwas null and this returns original
              return this;
            }
        Severity: Minor
        Found in java/core/src/main/java/com/whylogs/core/views/ColumnProfileView.java - 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 to_protobuf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_protobuf(self) -> MetricMessage:
                msg = {}
                for sub_name, metrics in self.submetrics.items():
                    for namespace, metric in metrics.items():
                        sub_msg = metric.to_protobuf()
        Severity: Minor
        Found in python/whylogs/experimental/extras/embedding_metric.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 columnar_update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def columnar_update(self, data: PreprocessedColumn) -> OperationResult:
                vectors = data.list.tensors if data.list.tensors else []
                vectors = vectors + (data.pandas.tensors.tolist() if data.pandas.tensors else [])
        
                if not vectors:
        Severity: Minor
        Found in python/whylogs/experimental/extras/nlp_metric.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

        Severity
        Category
        Status
        Source
        Language