tum-esm/utils

View on GitHub

Showing 21 of 35 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 278 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 273 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 `em27` dependency:
    Severity: Minor
    Found in tum_esm_utils/em27.py - About 2 hrs to fix

      OpusHTTPInterface has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class OpusHTTPInterface:
          """Interface to the OPUS HTTP interface.
      
          It uses the socket library, because the HTTP interface of OPUS does not
          reuturn valid HTTP/1 or HTTP/2 headers. It opens and closes a new socket
      Severity: Minor
      Found in tum_esm_utils/opus/http_interface.py - About 2 hrs to fix

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

            def read(
                filepath: str,
                measurement_timestamp_mode: Literal["start", "end"] = "start",
                interferogram_mode: Literal["skip", "validate", "read"] = "read",
                read_all_channels: bool = True,
        Severity: Minor
        Found in tum_esm_utils/opus/file_interface.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 timing.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Functions used for timing or time calculations.
        
        Implements: `date_range`, `ensure_section_duration`, `set_alarm`,
        `clear_alarm`, `wait_for_condition`, `ExponentialBackoff`"""
        
        
        Severity: Minor
        Found in tum_esm_utils/timing.py - About 2 hrs to fix

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

              def some_macro_is_running() -> bool:
                  """Check if any macro is currently running.
          
                  In theory, we could also check whether the correct macro is running using
                  `READ_PARAMETER MPT` and `READ_PARAMETER MFN`. However, these variables do
          Severity: Minor
          Found in tum_esm_utils/opus/http_interface.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_opus_block has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def read_opus_block(
              f: io.BufferedReader,
              opus_directory_entry: types.OpusDirectoryEntry,
              expected_block_type: type[T],
          ) -> T:
          Severity: Minor
          Found in tum_esm_utils/opus/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 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 read_interferogram has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def read_interferogram(
              f: io.BufferedReader,
              channel_parameters: list[types.OpusChannelParameters],
              ifg_opus_dirs: list[types.OpusDirectoryEntry],
              read_all_channels: bool = True,
          Severity: Minor
          Found in tum_esm_utils/opus/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 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 sleep has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def sleep(self, max_sleep_time: Optional[float] = None) -> float:
                  """Wait and increase the wait time to the next bucket.
          
                  Args:
                      max_sleep_time: The maximum time to sleep. If None, no maximum is set.
          Severity: Minor
          Found in tum_esm_utils/timing.py - About 55 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 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 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 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

                    Severity
                    Category
                    Status
                    Source
                    Language