Showing 57 of 57 total issues

File adi.py has 680 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import math
import re
from typing import Any, Dict, List

Severity: Major
Found in tsdat/transform/adi.py - About 1 day to fix

    File acdd_global_attrs.py has 533 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from pydantic import (
        Field,
        HttpUrl,
    )
    
    
    Severity: Major
    Found in tsdat/config/attributes/acdd_global_attrs.py - About 1 day to fix

      Function perform_data_retrieval has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

      def perform_data_retrieval(
              input_data: Dict[InputKey, xr.Dataset],
              coord_rules: Dict[VarName, Dict[Pattern[Any], RetrievedVariable]],
              data_var_rules: Dict[VarName, Dict[Pattern[Any], RetrievedVariable]],
      ) -> Tuple[RetrievedDataset, RetrievalRuleSelections]:
      Severity: Minor
      Found in tsdat/io/retrievers/perform_data_retrieval.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 _rename_variables has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      def _rename_variables(
              dataset: xr.Dataset,
              input_config: InputKeyRetrievalRules,
      ) -> xr.Dataset:
          """-----------------------------------------------------------------------------
      Severity: Minor
      Found in tsdat/io/retrievers/_rename_variables.py - About 3 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 retrieve has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def retrieve(
                  self,
                  input_keys: List[str],
                  dataset_config: DatasetConfig,
                  storage: Optional[Storage] = None,
      Severity: Minor
      Found in tsdat/io/retrievers/storage_retriever.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 run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(
                  self, dataset: xr.Dataset, variable_name: str
          ) -> Union[NDArray[np.bool_], None]:
              variable = dataset[variable_name]
              failures = np.full(variable.shape, False)
      Severity: Minor
      Found in tsdat/qc/checkers/check_monotonic.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

      File utils.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      import re
      from datetime import datetime
      from enum import Enum
      from pathlib import Path
      Severity: Minor
      Found in tsdat/utils.py - About 2 hrs to fix

        Function _write_transform_parameter_row has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def _write_transform_parameter_row(
                self,
                transforms: Dict[str, str],
                file_name: str,
                base_var_name: str,
        Severity: Minor
        Found in tsdat/transform/adi.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 read has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def read(self, input_key: str) -> Dict[str, xr.Dataset]:
                """------------------------------------------------------------------------------------
                Extracts the file into memory and uses registered `DataReaders` to read each relevant
                extracted file into its own xarray Dataset object. Returns a mapping like
                {filename: xr.Dataset}.
        Severity: Minor
        Found in tsdat/io/readers/zip_reader.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

        File converters.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from datetime import datetime
        import warnings
        import logging
        from typing import TYPE_CHECKING, Any, Dict, Hashable, List, Literal, Optional, Tuple
        
        
        Severity: Minor
        Found in tsdat/transform/converters.py - About 2 hrs to fix

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

              def write(
                      self, dataset: xr.Dataset, filepath: Optional[Path] = None, **kwargs: Any
              ) -> None:
                  to_netcdf_kwargs = copy.deepcopy(self.parameters.to_netcdf_kwargs)
                  encoding_dict: Dict[str, Dict[str, Any]] = {}
          Severity: Minor
          Found in tsdat/io/writers/netcdf_writer.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 recursive_instantiate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def recursive_instantiate(model: Any) -> Any:
              """---------------------------------------------------------------------------------
              Instantiates all ParametrizedClass components and subcomponents of a given model.
          
              Recursively calls model.instantiate() on all ParameterizedConfigClass instances under
          Severity: Minor
          Found in tsdat/config/utils/recursive_instantiate.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 read has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def read(self, input_key: str) -> Dict[str, xr.Dataset]:
                  """------------------------------------------------------------------------------------
                  Extracts the file into memory and uses registered `DataReaders` to read each relevant
                  extracted file into its own xarray Dataset object. Returns a mapping like
                  {filename: xr.Dataset}.
          Severity: Minor
          Found in tsdat/io/readers/tar_reader.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 write has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def write(
                      self, dataset: xr.Dataset, filepath: Optional[Path] = None, **kwargs: Any
              ) -> None:
                  to_netcdf_kwargs = copy.deepcopy(self.parameters.to_netcdf_kwargs)
                  encoding_dict: Dict[str, Dict[str, Any]] = {}
          Severity: Minor
          Found in tsdat/io/writers/split_netcdf_writer.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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(
                      self,
                      input_key: InputKey,
                      coord_rules: Dict[VarName, Dict[Pattern[Any], RetrievedVariable]],
                      data_var_rules: Dict[VarName, Dict[Pattern[Any], RetrievedVariable]],
          Severity: Minor
          Found in tsdat/io/retrievers/input_key_retrieval_rules.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 _run_data_converters has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def _run_data_converters(
                  dataset: xr.Dataset,
                  dataset_config: DatasetConfig,
                  input_config: InputKeyRetrievalRules,
          ) -> xr.Dataset:
          Severity: Minor
          Found in tsdat/io/retrievers/_run_data_converters.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 decode_cf has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def decode_cf(dataset: xr.Dataset) -> xr.Dataset:
              """---------------------------------------------------------------------------------
              Wrapper around `xarray.decode_cf()` which handles additional edge cases.
          
              This helps ensure that the dataset is formatted and encoded correctly after it has
          Severity: Minor
          Found in tsdat/utils.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 _substitute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def _substitute(
              template: str,
              mapping: Mapping[str, str | Callable[[], str] | None] | None = None,
              allow_missing: bool = False,
              **kwds: str | Callable[[], str] | None,
          Severity: Minor
          Found in tsdat/tstring.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 write has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def write(
                      self, dataset: xr.Dataset, filepath: Optional[Path] = None, **kwargs: Any
              ) -> None:
                  # QUESTION: Is this format capable of "round-tripping"?
                  # (i.e., ds != read(write(ds)) for csv format)
          Severity: Minor
          Found in tsdat/io/writers/csv_writer.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 _add_atts_to_adi has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def _add_atts_to_adi(self, xr_var: xr.DataArray, adi_obj: CDSObject):
                  encoding_atts = {
                      att: xr_var.encoding[att]
                      for att in ["_FillValue", "source", "units"]
                      if att in xr_var.encoding
          Severity: Minor
          Found in tsdat/transform/adi.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

          Severity
          Category
          Status
          Source
          Language