whylabs/whylogs-python

View on GitHub

Showing 236 of 3,918 total issues

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

    def columnar_update(self, data: PreprocessedColumn) -> OperationResult:
        # Should be data.list.objs  [ List[str] ] from scalar
        #           data.pandas.obj Series[List[str]] from apply
        doc_lengths = list()
        if data.list.objs and isinstance(data.list.objs[0], list) and _all_strings(data.list.objs[0]):
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

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

    def _get_time_tuple(self) -> time.struct_time:
        if self.utc:
            time_tuple = time.gmtime(self._current_batch_timestamp)
        else:
            time_tuple = time.localtime(self._current_batch_timestamp)
Severity: Minor
Found in python/whylogs/api/logger/rolling.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 initialize_logger has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def initialize_logger() -> None:
    # Initialize session
    n_attempts = 3
    while n_attempts > 0:
        # Initialize logger
Severity: Minor
Found in python/examples/integrations/flask_streaming/api/utils.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 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

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

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

    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

      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 write has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def write(
                self, file: _Writable, dest: Optional[str] = None, **kwargs: Any
            ) -> Tuple[bool, Union[str, List[Tuple[bool, str]]]]:
                self._whylabs_client = self._whylabs_client.option(**kwargs)  # type: ignore
                if isinstance(file, FeatureWeights):
        Severity: Minor
        Found in python/whylogs/api/writer/whylabs.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 get_pil_image_statistics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_pil_image_statistics(
            img: ImageType, channels: List[str] = _IMAGE_HSV_CHANNELS, image_stats: List[str] = _STATS_PROPERTIES
        ) -> Dict:
            """
            Compute statistics data for a PIL Image
        Severity: Minor
        Found in python/whylogs/extras/image_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 _calculate_descriptive_statistics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def _calculate_descriptive_statistics(
            column_view: Union[ColumnProfileView, None]
        ) -> Union[None, DescriptiveStatistics]:
            if column_view is None:
                return None
        Severity: Minor
        Found in python/whylogs/viz/utils/descriptive_stats.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 _get_segments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_segments(self, reference_results: SegmentedResultSet, target_results: SegmentedResultSet):
                if len(reference_results.partitions) > 1 and len(target_results.partitions) > 1:
                    logger.warning("More than one partition found. Only the first partition will be used for the estimation.")
                if len(reference_results.partitions) != len(target_results.partitions):
                    raise ValueError("The number of partitions in the reference and target results must be the same.")
        Severity: Minor
        Found in python/whylogs/experimental/performance_estimation/estimators.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, resolvers: List[ResolverSpec], default_config: Optional[MetricConfig] = None) -> None:
                super().__init__(resolvers, default_config)
                for resolver in resolvers:
                    for metric_spec in resolver.metrics:
                        if issubclass(metric_spec.metric, MultiMetric) and not resolver.exclude:
        Severity: Minor
        Found in python/whylogs/experimental/core/metrics/udf_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 generate_profile_summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def generate_profile_summary(
            target_view: DatasetProfileView, config: Optional[SummaryConfig]
        ) -> Optional[Dict[str, Any]]:
            if config is None:
                config = SummaryConfig()
        Severity: Minor
        Found in python/whylogs/viz/utils/profile_viz_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

        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

        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 condition_validator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def condition_validator(
            col_names: Union[str, List[str]],
            condition_name: Optional[str] = None,
            actions: Union[
                List[Callable[[str, str, Any, Optional[Any]], None]], Callable[[str, str, Any, Optional[Any]], None]
        Severity: Minor
        Found in python/whylogs/experimental/core/validators/condition_validator.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

        Severity
        Category
        Status
        Source
        Language