LiberTEM/LiberTEM

View on GitHub

Showing 269 of 913 total issues

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

def radial_bins(centerX, centerY, imageSizeX, imageSizeY,
Severity: Major
Found in src/libertem/masks.py - About 45 mins to fix

    Function allocate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def allocate(self, lib=None):
            """
            Allocate a buffer as a dask array
    
            nav buffer chunking is made identical to the partition structure
    Severity: Minor
    Found in src/libertem/executor/utils/dask_buffer.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 to_sparse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def to_sparse(a, shape: Optional[Union['Shape', tuple[int, ...]]] = None):
        if isinstance(a, sparse.COO):
            return a
        elif isinstance(a, sparse.SparseArray):
            return sparse.COO(a)
    Severity: Minor
    Found in src/libertem/common/sparse.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

    Avoid deeply nested control flow statements.
    Open

                            with tracer.start_as_current_span("SHUTDOWN"):
                                queues.request.close()
                                queues.response.close(drain=False)
                                queues.message.close(drain=False)
                            break
    Severity: Major
    Found in src/libertem/executor/pipelined.py - About 45 mins to fix

      Function data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def data(self):
              """
              Get the buffer contents in shape that corresponds to the
              original dataset shape, using a lazy Dask array.
      
      
      Severity: Minor
      Found in src/libertem/executor/utils/dask_buffer.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 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

      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

        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

          Function __setitem__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __setitem__(self, key, value: Union[nt.ArrayLike, Number]):
                  if not np.isscalar(value) and value.size == 1 and not isinstance(value, dask.array.Array):
                      # Avoids deprecated Numpy behaviour of implicitly
                      # extracting a scalar from an array during assignment
                      value = value.item()
          Severity: Minor
          Found in src/libertem/executor/utils/dask_inplace.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

          Avoid deeply nested control flow statements.
          Open

                                  if __threadpool_counter == 0:
                                      # The limit is set upon calling ThreadpoolController.limit()
                                      __threadpool_limiter = __threadpool_wrapper(n)
                                  __threadpool_counter += 1
          Severity: Major
          Found in src/libertem/common/threading.py - About 45 mins to fix

            Function _compute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def _compute(self, *args, udfs=None, user_backends=None, traverse=True, **kwargs):
                    """
                    Acts as dask.compute(*args, **kwargs) but with knowledge
                    of Libertem data structures and compute resources
                    """
            Severity: Minor
            Found in src/libertem/executor/delayed.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

            Avoid deeply nested control flow statements.
            Open

                                    with tracer.start_as_current_span("WARMUP"):
                                        import libertem.udf.base  # NOQA
                                        import libertem.api  # NOQA
                                        import libertem.preload  # NOQA
                                        with env.enter():
            Severity: Major
            Found in src/libertem/executor/pipelined.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

                                    for index in repair_environments[i, :repair_counts[i]]:
                                        acc += buffer[nav, index]
                                    buffer[nav, p] = acc / repair_counts[i]
                Severity: Major
                Found in src/libertem/io/corrections/detector.py - About 45 mins to fix

                  Function analysisReducer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const analysisReducer = (state = initialAnalysisState, action: AllActions): AnalysisReducerState => {
                      switch (action.type) {
                          case analysisActions.ActionTypes.CREATED: {
                              return insertById(state, action.payload.analysis.id, action.payload.analysis);
                          }
                  Severity: Minor
                  Found in client/src/analysis/reducers.ts - 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_tiles has 10 arguments (exceeds 8 allowed). Consider refactoring.
                  Open

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

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

                        def get_tiles(
                    Severity: Major
                    Found in src/libertem/io/dataset/base/backend.py - About 45 mins 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 __init__ has 10 arguments (exceeds 8 allowed). Consider refactoring.
                        Open

                            def __init__(self, path, ds_path=None, tileshape=None, nav_shape=None, sig_shape=None,
                        Severity: Major
                        Found in src/libertem/io/dataset/hdf5.py - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language