whylabs/whylogs-python

View on GitHub

Showing 3,656 of 3,656 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  $closeIcon.on("click", function () {
    $signUpText.addClass("d-none");
    sidebarContentHeight()
    $(".open-sign-up-text-notif-container").removeClass("d-none")
  });
Severity: Minor
Found in python/whylogs/viz/html/js/whylogs-script.js and 1 other location - About 40 mins to fix
python/whylogs/viz/html/js/whylogs-script.js on lines 1466..1470

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 49.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        let {
          MARGIN,
          SVG_WIDTH,
          SVG_HEIGHT,
          CHART_WIDTH,
    Severity: Minor
    Found in python/whylogs/viz/html/js/whylogs-script.js and 1 other location - About 40 mins to fix
    python/whylogs/viz/html/js/whylogs-script.js on lines 340..349

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        let {
          MARGIN,
          SVG_WIDTH,
          SVG_HEIGHT,
          CHART_WIDTH,
    Severity: Minor
    Found in python/whylogs/viz/html/js/whylogs-script.js and 1 other location - About 40 mins to fix
    python/whylogs/viz/html/js/whylogs-script.js on lines 253..262

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 48.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    def _log_segment(
        partition: SegmentationPartition,
        schema: DatasetSchema,
        obj: Any = None,
        pandas: Optional[pd.DataFrame] = None,
    Severity: Minor
    Found in python/whylogs/api/logger/segment_processing.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 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 _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 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 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 _generate_segment_tags_metadata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _generate_segment_tags_metadata(
        segment: Segment, partition: SegmentationPartition
    ) -> Tuple[Dict[str, str], List[SegmentTag], Dict[str, str]]:
        segment_metadata: Optional[Dict[str, str]] = None
        segment_tags: Optional[List[SegmentTag]] = None
    Severity: Minor
    Found in python/whylogs/migration/converters.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

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

        def _process_flush_message(self, message: FlushMessage) -> None:
            for dataset_timestamp, container in self._cache.items():
                self._logger.debug(f"Generating result set for dataset timestamp {dataset_timestamp}")
    
                result_set = container.to_result_set()

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

    def _convert_to_int_if_bool(data: pd.core.frame.DataFrame, *columns: str) -> pd.core.frame.DataFrame:
        for col in columns:
            if all(isinstance(x, bool) for x in data[col]):
                data[col] = data[col].apply(lambda x: 1 if x else 0)
        return data
    Severity: Minor
    Found in python/whylogs/experimental/api/logger/__init__.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

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

        def resolve(
            self,
            *,
            pandas: Optional[pd.DataFrame] = None,
            row: Optional[Mapping[str, Any]] = None,
    Severity: Minor
    Found in python/whylogs/core/schema.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

    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 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

    Severity
    Category
    Status
    Source
    Language