whylabs/whylogs-python

View on GitHub

Showing 3,918 of 3,918 total issues

Avoid deeply nested control flow statements.
Open

                    if _is_nan(val):
                        evaluations.append((pandas[col].isna()))
                    else:
                        evaluations.append((pandas[col] == val))
                mask = reduce(lambda x, y: x & y, evaluations)
Severity: Major
Found in python/whylogs/api/logger/segment_processing.py - About 45 mins to fix

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

        def calc_non_numeric_relevance(self, row_dict: pd.core.series.Series) -> Tuple[List[int], List[int]]:
            prediction_relevance = []
            ideal_relevance = []
            for target_val in row_dict[self.prediction_column]:
                ideal_relevance.append(1 if target_val in row_dict[self.target_column] else 0)
    Severity: Minor
    Found in python/whylogs/experimental/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 _load_or_prompt has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _load_or_prompt(
            self,
            env_name: EnvVariableName,
            config_name: ConfigVariableName,
            persist: bool = False,
    Severity: Minor
    Found in python/whylogs/api/whylabs/session/config.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 log_debug_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def log_debug_event(
            self,
            debug_event: Optional[Dict[str, Any]] = None,
            *,
            trace_id: str,
    Severity: Minor
    Found in python/whylogs/api/logger/events/event.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,
            aggregate_by: TimeGranularity = TimeGranularity.Hour,
            write_schedule: Optional[Schedule] = Schedule(cadence=TimeGranularity.Minute, interval=10),
            schema: Optional[DatasetSchema] = None,

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

    Avoid deeply nested control flow statements.
    Open

                            if spec.metric.get_namespace() in result:
                                logger.warning(
                                    f"Conflicting resolvers for {spec.metric.get_namespace()} metric in column '{name}' of type {why_type.return_type.__name__}"
                                )
                            result[spec.metric.get_namespace()] = spec.metric.zero(cfg)
    Severity: Major
    Found in python/whylogs/core/resolvers.py - About 45 mins to fix

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

          def write(
              self,
              file: _Writable,
              dest: Optional[str] = None,
              **kwargs: Any,
      Severity: Minor
      Found in python/whylogs/api/writer/s3.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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def write(
              self,
              file: _Writable,
              dest: Optional[str] = None,  # TODO: this should be used as object_name
              **kwargs: Any,
      Severity: Minor
      Found in python/whylogs/api/writer/gcs.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 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

          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

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

            $openSignUpText.on("click", function () {
              $signUpText.removeClass("d-none");
              sidebarContentHeight()
              $(".open-sign-up-text-notif-container").addClass("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 1460..1464

          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

          Severity
          Category
          Status
          Source
          Language