tum-esm/utils

View on GitHub

Showing 14 of 28 total issues

Function terminate_process has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def terminate_process(
    script_path: str,
    termination_timeout: Optional[int] = None,
) -> list[int]:
    """Terminate all processes that have the given script as their
Severity: Minor
Found in tum_esm_utils/processes.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

File text.py has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Functions used for text manipulation/processing.

Implements: `get_random_string`, `pad_string`, `is_date_string`,
`is_rfc3339_datetime_string`, `insert_replacements`, `simplify_string_characters`,
`replace_consecutive_characters`, `RandomLabelGenerator`"""
Severity: Minor
Found in tum_esm_utils/text.py - About 2 hrs to fix

    File em27.py has 280 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Functions for interacting with EM27 interferograms.
    
    Implements: `detect_corrupt_opus_files`, `load_proffast2_result`.
    
    This requires you to install this utils library with the optional `polars` dependency:
    Severity: Minor
    Found in tum_esm_utils/em27.py - About 2 hrs to fix

      Function parse_timezone_string has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_timezone_string(
          timezone_string: str,
          dt: Optional[datetime.datetime] = None,
      ) -> float:
          """Parse a timezone string and return the offset in hours.
      Severity: Minor
      Found in tum_esm_utils/timing.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 read_last_n_lines has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def read_last_n_lines(
          file_path: str,
          n: int,
          ignore_trailing_whitespace: bool = False,
      ) -> list[str]:
      Severity: Minor
      Found in tum_esm_utils/files.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 merge_dicts has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def merge_dicts(old_object: Any, new_object: Any) -> Any:
          """
          For a given dict, update it recursively from a new dict.
          It will not add any properties and assert that the types
          remain the same (or null). null->int or int->null is possible
      Severity: Minor
      Found in tum_esm_utils/datastructures.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 detect_corrupt_opus_files has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def detect_corrupt_opus_files(
          ifg_directory: str,
          silent: bool = True,
          fortran_compiler: Literal["gfortran", "gfortran-9"] = "gfortran",
          force_recompile: bool = False,
      Severity: Minor
      Found in tum_esm_utils/em27.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 request_gitlab_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def request_gitlab_file(
      Severity: Minor
      Found in tum_esm_utils/code.py - About 45 mins to fix

        Function add_subplot has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def add_subplot(
        Severity: Minor
        Found in tum_esm_utils/plotting.py - About 45 mins to fix

          Function list_directory has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def list_directory(
          Severity: Minor
          Found in tum_esm_utils/files.py - About 45 mins to fix

            Function render_directory_tree has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def render_directory_tree(
            Severity: Minor
            Found in tum_esm_utils/files.py - About 45 mins to fix

              Function request_github_file has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def request_github_file(
              Severity: Minor
              Found in tum_esm_utils/code.py - About 35 mins to fix

                Function parse_iso_8601_datetime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def parse_iso_8601_datetime(s: str) -> datetime.datetime:
                    """Parse a datetime string from various formats and return a datetime object.
                    
                    ISO 8601 supports time zones as `<time>Z`, `<time>±hh:mm`, `<time>±hhmm` and
                    `<time>±hh`. However, only the second format is supported by `datetime.datetime.fromisoformat()`
                Severity: Minor
                Found in tum_esm_utils/timing.py - About 25 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 _compile_fortran_code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def _compile_fortran_code(
                    silent: bool = True,
                    fortran_compiler: Literal["gfortran", "gfortran-9"] = "gfortran",
                    force_recompile: bool = False,
                ) -> None:
                Severity: Minor
                Found in tum_esm_utils/em27.py - About 25 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