LiberTEM/LiberTEM

View on GitHub
src/libertem/common/buffers.py

Summary

Maintainability
D
2 days
Test Coverage

File buffers.py has 825 lines of code (exceeds 400 allowed). Consider refactoring.
Open

from typing import Any, Optional, Union, TYPE_CHECKING, Generic, TypeVar
from collections.abc import Iterable
from typing_extensions import Literal
import mmap
import math
Severity: Major
Found in src/libertem/common/buffers.py - About 1 day to fix

    Function get_view_for_frame has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_view_for_frame(self, partition, tile, frame_idx):
            """
            get a view for a single frame in a partition- or dataset-sized buffer
            (partition-sized here means the reduced result for a whole partition,
            not the partition itself!)
    Severity: Minor
    Found in src/libertem/common/buffers.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 _shape_for_kind has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _shape_for_kind(self, kind, orig_shape, roi_count=None):
            """
            :meta private:
            """
            if self._kind == "nav":
    Severity: Minor
    Found in src/libertem/common/buffers.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 get_contiguous_view_for_tile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_contiguous_view_for_tile(self, partition, tile):
            '''
            Make a cached contiguous copy of the view for a single tile
            if necessary.
    
    
    Severity: Minor
    Found in src/libertem/common/buffers.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_view_for_tile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_view_for_tile(self, partition, tile):
            """
            get a view for a single tile in a partition-sized buffer
            (partition-sized here means the reduced result for a whole partition,
            not the partition itself!)
    Severity: Minor
    Found in src/libertem/common/buffers.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 data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def data(self):
            """
            Get the buffer contents in shape that corresponds to the
            original dataset shape. If a ROI is set, embed the result into a new
            array; unset values have NaN value for floating point types,
    Severity: Minor
    Found in src/libertem/common/buffers.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 flush has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def flush(self, debug=False):
            '''
            Write back any cached contiguous copies
    
            .. versionadded:: 0.5.0
    Severity: Minor
    Found in src/libertem/common/buffers.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

    Error: invalid syntax (<unknown>, line 19)</unknown>
    Open

            while batch := tuple(itertools.islice(it, n)):
    Severity: Minor
    Found in src/libertem/common/buffers.py by radon

    We encountered an error attempting to analyze this line.

    There are no issues that match your filters.

    Category
    Status