LiberTEM/LiberTEM

View on GitHub

Showing 270 of 903 total issues

Function _order_results has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _order_results(results_in: ResultWithID) -> ResultT:
    """
    Order the `results_in` generator by the result id, yielding ordered results.
    Requires indexes to be without gaps.
    """
Severity: Minor
Found in src/libertem/executor/pipelined.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 read_tiles_with_roi has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def read_tiles_with_roi(
    triple: CSRTriple,
    partition_slice: Slice,
    sync_offset: int,
    tiling_scheme: TilingScheme,
Severity: Minor
Found in src/libertem/io/dataset/raw_csr.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 flatten_filter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def flatten_filter(excluded_pixels, repairs, repair_counts, sig_shape):
    '''
    Flatten excluded pixels and repair environments and filter for collisions

    Ravel indices to flattened signal dimension and
Severity: Minor
Found in src/libertem/io/corrections/detector.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 async_to_sync_generator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def async_to_sync_generator(agen, pool=None):
    span = trace.get_current_span()
    span_context = span.get_span_context()
    q = queue.Queue()
    t = AsyncGenToQueueThread(agen, q, span_context)
Severity: Minor
Found in src/libertem/common/async_utils.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 _start_pool has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _start_pool(self) -> WorkerPool:
        with tracer.start_as_current_span("PipelinedExecutor.start_pool") as span:
            pool = WorkerPool(
                worker_fn=functools.partial(
                    pipelined_worker,
Severity: Minor
Found in src/libertem/executor/pipelined.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 _get_dependencies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def _get_dependencies(self, cvar):
            deps = [cvar]
            if hasattr(cvar, 'py_func'):
                # TODO: does the cache key need to depend on any other
                # attributes of the Dispatcher?
Severity: Minor
Found in src/libertem/common/numba/cache.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 calc_coords has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def calc_coords(self, indices=None, drop_zero=False, frame_shape=None, r=0):
        '''
        Shorthand to calculate peak coordinates.

        Parameters
Severity: Minor
Found in src/libertem/analysis/gridmatching.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 main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def main(kind, scheduler, local_directory, n_cpus, cudas,
         has_cupy, name, log_level, preload: tuple[str, ...]):
    from libertem.common.threading import set_num_threads_env
    with set_num_threads_env(1):
        from libertem.utils.devices import detect
Severity: Minor
Found in src/libertem/executor/cli.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 _get_subslices has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_subslices(self, tiling_scheme):
        """
        Generate partition subslices for the given tiling scheme for the different cases.
        """
        if tiling_scheme.intent == "partition":
Severity: Minor
Found in src/libertem/io/dataset/hdf5.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 __init__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, masks: MaskContainer, meta: UDFMeta, use_torch: bool):
        self.masks = masks
        self.meta = meta

        try:
Severity: Minor
Found in src/libertem/udf/masks.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 adjustShapeWithBounds has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const adjustShapeWithBounds = (shape: string, shapeType: "nav"|"sig"): string => {
    const { minLength, maxLength } = getMinAndMaxShapeLength(shapeType);

    let adjustedShape = new Array<string>(minLength).fill("");

Severity: Minor
Found in client/src/dataset/helpers.ts - 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 _init_udfs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _init_udfs(
        self,
        execution_plan: ExecutionPlan,
        partition: Partition,
        roi: Optional[np.ndarray],
Severity: Minor
Found in src/libertem/udf/base.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 GPUSelector has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const GPUSelector: React.FC<GPUSelectorProps> = ({
    config, name, value, setFieldValue,
}) => {
    const hasCupy = config.devices.has_cupy;
    const cudaIds = config.devices.cudas;
Severity: Minor
Found in client/src/cluster/components/GPUSelector.tsx - 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 _get_datasets has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _get_datasets(path):
    datasets: list[HDF5ArrayDescriptor] = []

    try:
        timeout = int(os.environ.get('LIBERTEM_IO_HDF5_TIMEOUT_DEBUG', 3))
Severity: Minor
Found in src/libertem/io/dataset/hdf5.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 get_tiles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_tiles(self, *args, **kwargs):
        if args and isinstance(args[0], TilingScheme):
            tiling_scheme = args[0]
            args = args[1:]
            intent = tiling_scheme.intent
Severity: Minor
Found in src/libertem/io/dataset/memory.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 run has 11 arguments (exceeds 8 allowed). Consider refactoring.
Open

def run(
Severity: Major
Found in src/libertem/web/server.py - About 50 mins to fix

    Function _buffered_tilereader has 11 arguments (exceeds 8 allowed). Consider refactoring.
    Open

        def _buffered_tilereader(outer_idx, buffers, sig_dims, tile_read_ranges,
    Severity: Major
    Found in src/libertem/io/dataset/base/backend_buffered.py - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if __threadpool_counter == 0 and __threadpool_limiter is not None:
                                  __threadpool_limiter.restore_original_limits()
                                  __threadpool_limiter = None
      
      
      Severity: Major
      Found in src/libertem/common/threading.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for t in p.get_tiles(tiling_scheme=tiling_scheme, roi=roi):
                                found_first_tile = True
                                break
        
        
        Severity: Major
        Found in src/libertem/web/dataset.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if found_first_tile:
                                  break
                              p.set_corrections(corrections)
          Severity: Major
          Found in src/libertem/web/dataset.py - About 45 mins to fix
            Severity
            Category
            Status
            Source
            Language