LiberTEM/LiberTEM

View on GitHub

Showing 270 of 903 total issues

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

    def __init__(self, path, dtype, scan_size=None, detector_size=None, enable_direct=False,
                 detector_size_raw=None, crop_detector_to=None, tileshape=None,
                 nav_shape=None, sig_shape=None, sync_offset=0, io_backend=None):
        if enable_direct and io_backend is not None:
            raise ValueError("can't specify io_backend and enable_direct at the same time")
Severity: Minor
Found in src/libertem/io/dataset/raw.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 get_tiles has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def get_tiles(
        self, decoder, tiling_scheme, fileset, read_ranges, roi, native_dtype, read_dtype,
        sync_offset, corrections, array_backend: ArrayBackend,
    ):
        if roi is None:
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

File tiling_scheme.py has 424 lines of code (exceeds 400 allowed). Consider refactoring.
Open

import math
import logging
import warnings
from typing import TYPE_CHECKING, Optional, Union
from collections.abc import Sequence
Severity: Minor
Found in src/libertem/io/dataset/base/tiling_scheme.py - About 2 hrs to fix

    File gridmatching.py has 421 lines of code (exceeds 400 allowed). Consider refactoring.
    Open

    import warnings
    
    import numpy as np
    from libertem.utils import calc_coords, within_frame
    
    
    Severity: Minor
    Found in src/libertem/analysis/gridmatching.py - About 2 hrs to fix

      Messages has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export const Messages = {
          initialState: (
              jobs: MsgPartJob[],
              datasets: MsgPartInitialDataset[],
              analyses: MsgPartAnalysis[],
      Severity: Minor
      Found in client/src/channel/messages.ts - About 2 hrs to fix

        Function get_tiles has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_tiles(self, tiling_scheme: TilingScheme, dest_dtype="float32", roi=None,
                    array_backend: Optional[ArrayBackend] = None):
                if array_backend is None:
                    array_backend = self.meta.array_backends[0]
                assert array_backend in (NUMPY, CUDA)
        Severity: Minor
        Found in src/libertem/io/dataset/ser.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 get_partitions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_partitions(self):
                # ds_shape = Shape(self.shape, sig_dims=self.sig_dims)
                ds_shape: Shape = self.meta['ds_raw_shape']
                ds_slice = Slice(origin=[0] * len(ds_shape), shape=ds_shape)
                target_size = self.target_size
        Severity: Minor
        Found in src/libertem/io/dataset/hdf5.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 process_tile has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        def process_tile(tile, n_0, sum_inout, varsum_inout):
            '''
            Compute sum and variance of :code:`tile` along navigation axis
            and merge into aggregation buffers. Numerical "workhorse" for
            :meth:`StdDevUDF.process_tile`.
        Severity: Minor
        Found in src/libertem/udf/stddev.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 results_for_dataset_sync has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def results_for_dataset_sync(
                self,
                dataset: DataSet,
                executor: JobExecutor,
                roi: Optional[np.ndarray] = None,
        Severity: Minor
        Found in src/libertem/udf/base.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

        File dask.py has 416 lines of code (exceeds 400 allowed). Consider refactoring.
        Open

        import logging
        import itertools
        import numpy as np
        import dask.array as da
        
        
        Severity: Minor
        Found in src/libertem/io/dataset/dask.py - About 2 hrs to fix

          FRMS6DataSet has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class FRMS6DataSet(DataSet):
              r"""
              Read PNDetector FRMS6 files. FRMS6 data sets consist of multiple .frms6 files and
              a .hdr file. The first .frms6 file (matching \*_000.frms6) contains dark frames, which
              are subtracted if `enable_offset_correction` is true.
          Severity: Minor
          Found in src/libertem/io/dataset/frms6.py - About 2 hrs to fix

            Shape has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Shape:
                """
                Create a Shape that knows how many dimensions are part of navigation/signal.
                It is assumed that the signal is in the last `sig_dims` dimensions.
            
            
            Severity: Minor
            Found in src/libertem/common/shape.py - About 2 hrs to fix

              Function ClusterDetails has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const ClusterDetails = (details: HostDetails[]) => {
                  const [clustOverview, setOverview] = useState({
                      host: 0,
                      cpu: 0,
                      cuda: 0,
              Severity: Major
              Found in client/src/clusterStatus/components/TCPStatus.tsx - About 2 hrs to fix

                Function get_scheme has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_scheme(
                            self,
                            udfs: Sequence[UDFProtocol],
                            dataset,
                            read_dtype: "nt.DTypeLike",
                Severity: Minor
                Found in src/libertem/io/dataset/base/tiling_scheme.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

                File stddev.py has 410 lines of code (exceeds 400 allowed). Consider refactoring.
                Open

                from collections import defaultdict
                import functools
                
                import numpy as np
                import numba
                Severity: Minor
                Found in src/libertem/udf/stddev.py - About 2 hrs to fix

                  Function analysisReducer has 55 lines of code (exceeds 25 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: Major
                  Found in client/src/analysis/reducers.ts - About 2 hrs to fix

                    H5DataSet has 21 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class H5DataSet(DataSet):
                        """
                        Read data from a HDF5 data set.
                    
                        Examples
                    Severity: Minor
                    Found in src/libertem/io/dataset/hdf5.py - About 2 hrs to fix

                      Function insert_at_pos has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def insert_at_pos(el: Any,
                                        coords: list[tuple[type, Any]],
                                        nest: Iterable,
                                        merge_fns: dict[type, Callable[[Iterable, Any, Any], None]]):
                          """
                      Severity: Minor
                      Found in src/libertem/executor/utils/delayed_unpack.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 xml_defect_coord_extractor has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def xml_defect_coord_extractor(bad_pixel_map, map_index, map_sizes):
                          """
                          returns the chosen bad pixel map's defects
                      
                          Parameters
                      Severity: Minor
                      Found in src/libertem/io/dataset/seq.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 environments has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def environments(excluded_pixels, sigshape):
                          '''
                          Calculate a hypercube surface around a pixel, excluding frame boundaries
                      
                          Returns
                      Severity: Minor
                      Found in src/libertem/io/corrections/detector.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

                      Severity
                      Category
                      Status
                      Source
                      Language