LiberTEM/LiberTEM

View on GitHub

Showing 270 of 903 total issues

File state.py has 489 lines of code (exceeds 400 allowed). Consider refactoring.
Open

import os
import copy
import typing
import itertools
import logging
Severity: Minor
Found in src/libertem/web/state.py - About 4 hrs to fix

    Function prime_numba_cache has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def prime_numba_cache(ds):
        dtypes = (np.float32, None)
        for dtype in dtypes:
            roi = np.zeros(ds.shape.nav, dtype=bool).reshape((-1,))
            roi[max(-ds._meta.sync_offset, 0)] = True
    Severity: Minor
    Found in src/libertem/web/dataset.py - About 4 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 worker_loop has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def worker_loop(
        queues: WorkerQueues,
        work_mem: dict,
        worker_idx: int,
        env: Environment
    Severity: Minor
    Found in src/libertem/executor/pipelined.py - About 4 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

    Message has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Message:
        """
        possible messages - the translation of our python datatypes to json types
        """
    
    
    Severity: Minor
    Found in src/libertem/web/messages.py - About 3 hrs to fix

      DataSet has 31 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class DataSet:
          # The default partition size in bytes
          MAX_PARTITION_SIZE = 512*1024*1024
      
          def __init__(self, io_backend: Optional["IOBackend"] = None):
      Severity: Minor
      Found in src/libertem/io/dataset/base/dataset.py - About 3 hrs to fix

        Function _run_sync has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def _run_sync(
                self,
                dataset: DataSet,
                udf: Union[UDF, Iterable[UDF]],
                roi: RoiT,
        Severity: Minor
        Found in src/libertem/api.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 make_with has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def make_with(
                cls,
                executor_spec: ExecutorSpecType = 'dask',
                *,
                cpus: Optional[Union[int, Iterable[int]]] = None,
        Severity: Minor
        Found in src/libertem/api.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 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

        File cached.py has 459 lines of code (exceeds 400 allowed). Consider refactoring.
        Open

        import os
        import json
        import hashlib
        import sqlite3
        import time
        Severity: Minor
        Found in src/libertem/io/dataset/cached.py - About 3 hrs to fix

          Function block_get_min_fill_factor has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          def block_get_min_fill_factor(rrs):
              """
              Try to find out how sparse the given read ranges are, per file.
          
              Returns the smallest fill factor and maximum required buffer size.
          Severity: Minor
          Found in src/libertem/io/dataset/base/backend_buffered.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 jobReducer has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const jobReducer = (state = initialJobState, action: AllActions): JobReducerState => {
              switch (action.type) {
                  case jobActions.ActionTypes.CREATE: {
                      const createResult = insertById(
                          state,
          Severity: Major
          Found in client/src/job/reducers.ts - About 3 hrs to fix

            File tvips.py has 448 lines of code (exceeds 400 allowed). Consider refactoring.
            Open

            from io import SEEK_SET
            import math
            import os
            import re
            from typing import IO, TYPE_CHECKING, NamedTuple, Optional
            Severity: Minor
            Found in src/libertem/io/dataset/tvips.py - About 3 hrs to fix

              Function _apply_part_result has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _apply_part_result(self, udfs: Iterable[UDF], damage, part_results, task):
                      for part_results_udf, udf in zip(part_results, udfs):
                          # Allow user to define an alternative merge strategy
                          # using dask-compatible functions. In the Delayed case we
                          # won't be getting partial results with damage anyway.
              Severity: Minor
              Found in src/libertem/executor/delayed.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 getFormInitial has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

              const getFormInitial = (didReset: boolean, openState: OpenDatasetState) => {
                  const { formCachedParams, formDetectedParams } = openState;
                  if (didReset) {
                      if (formDetectedParams) {
                          return {
              Severity: Minor
              Found in client/src/dataset/components/DatasetOpen.tsx - 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

              UDFData has 26 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class UDFData:
                  '''
                  Container for result buffers, return value from running UDFs
                  '''
              
              
              Severity: Minor
              Found in src/libertem/udf/base.py - About 3 hrs to fix

                UDFBase has 26 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class UDFBase(UDFProtocol):
                    '''
                    Base class for UDFs with helper functions.
                    '''
                    def __init__(self, *args, **kwargs) -> None:
                Severity: Minor
                Found in src/libertem/udf/base.py - About 3 hrs to fix

                  Function actionsFromChannel has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function* actionsFromChannel(socketChannel: SocketChannel) {
                      try {
                          while (true) {
                              const msg = (yield take(socketChannel)) as channelMessages.Messages;
                              const timestamp = Date.now();
                  Severity: Major
                  Found in client/src/channel/sagas.ts - About 2 hrs to fix

                    Function __init__ has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __init__(self, tileshape=None, num_partitions=None, data=None, sig_dims=None,
                                     check_cast=True, tiledelay=None, datashape=None, base_shape=None,
                                     force_need_decode=False, io_backend=None,
                                     nav_shape=None, sig_shape=None, sync_offset=0, array_backends=None):
                            super().__init__(io_backend=io_backend)
                    Severity: Minor
                    Found in src/libertem/io/dataset/memory.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

                    Function decode_r1_swap_2x2 has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def decode_r1_swap_2x2(inp, out, idx, native_dtype, rr, origin, shape, ds_shape):
                        """
                        RAW 1bit format: each pixel is actually saved as a single bit. 64 bits
                        need to be unpacked together. This is the quad variant.
                    
                    
                    Severity: Minor
                    Found in src/libertem/io/dataset/mib.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

                    K2ISDataSet has 24 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class K2ISDataSet(DataSet):
                        """
                        Read raw K2IS data sets. They consist of 8 .bin files and one .gtg file.
                        Currently, data acquired using the STEMx unit is supported, metadata
                        about the nav_shape is read from the .gtg file.
                    Severity: Minor
                    Found in src/libertem/io/dataset/k2is.py - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language