LiberTEM/LiberTEM

View on GitHub
src/libertem/io/dataset/base/tiling.py

Summary

Maintainability
C
7 hrs
Test Coverage

Function make_get_read_ranges has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def make_get_read_ranges(
    px_to_bytes=_default_px_to_bytes,
    read_ranges_tile_block=_default_read_ranges_tile_block,
):
    """
Severity: Minor
Found in src/libertem/io/dataset/base/tiling.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 _default_read_ranges_tile_block has 16 arguments (exceeds 8 allowed). Consider refactoring.
Open

def _default_read_ranges_tile_block(
Severity: Major
Found in src/libertem/io/dataset/base/tiling.py - About 1 hr to fix

    Function _get_read_ranges_inner has 12 arguments (exceeds 8 allowed). Consider refactoring.
    Open

        def _get_read_ranges_inner(
    Severity: Major
    Found in src/libertem/io/dataset/base/tiling.py - About 1 hr to fix

      Function _default_px_to_bytes has 10 arguments (exceeds 8 allowed). Consider refactoring.
      Open

      def _default_px_to_bytes(
      Severity: Major
      Found in src/libertem/io/dataset/base/tiling.py - About 45 mins to fix

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

        def _find_file_for_frame_idx(fileset_arr, frame_idx):
            """
            Find the file in `fileset_arr` that contains
            `frame_idx` and return its index using binary search.
        
        
        Severity: Minor
        Found in src/libertem/io/dataset/base/tiling.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 "_default_read_ranges_tile_block" has 16 parameters, which is greater than the 7 authorized.
        Open

            slices_arr, fileset_arr, slice_sig_sizes, sig_origins,
            inner_indices_start, inner_indices_stop, frame_indices, sig_size,
            px_to_bytes, bpp, frame_header_bytes, frame_footer_bytes, file_idxs,
            slice_offset, extra, sig_shape,

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        def do_something(param1, param2, param3, param4, param5):
            ...
        

        Compliant Solution

        def do_something(param1, param2, param3, param4):
            ...
        

        Function "_get_read_ranges_inner" has 12 parameters, which is greater than the 7 authorized.
        Open

                start_at_frame, stop_before_frame, roi_nonzero, depth,
                slices_arr, fileset_arr, sig_shape,
                bpp, sync_offset=0, extra=None, frame_header_bytes=0, frame_footer_bytes=0,

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        def do_something(param1, param2, param3, param4, param5):
            ...
        

        Compliant Solution

        def do_something(param1, param2, param3, param4):
            ...
        

        Function "_default_px_to_bytes" has 10 parameters, which is greater than the 7 authorized.
        Open

            bpp, frame_in_file_idx, slice_sig_size, sig_size, sig_origin,
            frame_footer_bytes, frame_header_bytes, file_header_bytes,
            file_idx, read_ranges,

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        def do_something(param1, param2, param3, param4, param5):
            ...
        

        Compliant Solution

        def do_something(param1, param2, param3, param4):
            ...
        

        Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed.
        Open

        def make_get_read_ranges(

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        There are no issues that match your filters.

        Category
        Status