LiberTEM/LiberTEM

View on GitHub

Showing 270 of 903 total issues

Function get_fs_listing has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def get_fs_listing(path: str):
    try:
        abspath = Path(path).expanduser().resolve()
    # Triggered by empty DVD drive on Windows
    except PermissionError as e:
Severity: Minor
Found in src/libertem/io/fs.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 detect_shape has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def detect_shape(path: str) -> tuple[int, tuple[int, ...]]:
    series_header = read_series_header(path)

    if series_header.version != 2:
        raise DetectionError(
Severity: Minor
Found in src/libertem/io/dataset/tvips.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 run_each_partition has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def run_each_partition(self, partitions, fn, all_nodes=False):
        """
        Run `fn` for all partitions. Yields results in order of completion.

        Parameters
Severity: Minor
Found in src/libertem/executor/dask.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 disjunct_multiplier has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def disjunct_multiplier(excluded, sig_shape, base_shape=1, target=1):
    '''
    Calculate an integer i close to target which is a multiple of base_shape
    and for which i * n not in "excluded" for any n > 0, i * n < sig_shape.

Severity: Minor
Found in src/libertem/io/corrections/corrset.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 _parse_header_bytes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _parse_header_bytes(header: bytes, filesize: int) -> HeaderDict:
        header: str = header.decode(encoding='ascii', errors='ignore')
        parts = header.split(",")
        header_size_bytes = int(parts[2])
        parts = [p
Severity: Minor
Found in src/libertem/io/dataset/mib.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_tiles_normal has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_tiles_normal(self, tiling_scheme: TilingScheme, dest_dtype):
        with self._get_h5ds() as dataset:
            # because the dtype conversion done by HDF5 itself can be quite slow,
            # we need to use a buffer for reading in hdf5 native dtype:
            data_flat = np.zeros(tiling_scheme.shape, dtype=dataset.dtype).reshape((-1,))
Severity: Minor
Found in src/libertem/io/dataset/hdf5.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 array_backends has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def array_backends(self) -> Sequence[ArrayBackend]:
        """
        All backends can be returned on request

        .. versionadded:: 0.11.0
Severity: Minor
Found in src/libertem/io/dataset/memory.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 compoundAnalysisReducer has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const compoundAnalysisReducer = (state = initialCompoundAnalysisState, action: AllActions): CompoundAnalysisReducerState => {
    switch (action.type) {
        case compoundAnalysisActions.ActionTypes.CREATED: {
            const newCompoundAnalysis = {
                doAutoStart: action.payload.autoStart,
Severity: Minor
Found in client/src/compoundAnalysis/reducers.ts - About 1 hr to fix

    Function _frms6_read_ranges_tile_block has 16 arguments (exceeds 8 allowed). Consider refactoring.
    Open

    def _frms6_read_ranges_tile_block(
    Severity: Major
    Found in src/libertem/io/dataset/frms6.py - About 1 hr to fix

      Function _mib_2x2_tile_block has 16 arguments (exceeds 8 allowed). Consider refactoring.
      Open

      def _mib_2x2_tile_block(
      Severity: Major
      Found in src/libertem/io/dataset/mib.py - About 1 hr to fix

        Function _k2is_read_ranges_tile_block has 16 arguments (exceeds 8 allowed). Consider refactoring.
        Open

        def _k2is_read_ranges_tile_block(
        Severity: Major
        Found in src/libertem/io/dataset/k2is.py - About 1 hr to fix

          Function _read_block_dense has 16 arguments (exceeds 8 allowed). Consider refactoring.
          Open

              def _read_block_dense(
          Severity: Major
          Found in src/libertem/io/dataset/base/backend_buffered.py - About 1 hr to fix

            Function _default_read_ranges_tile_block has 16 arguments (exceeds 8 allowed). Consider refactoring.
            Open

            def _default_read_ranges_tile_block(
            Severity: Major
            Found in src/libertem/io/dataset/base/tiling.py - About 1 hr to fix

              Function createOrUpdate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function* createOrUpdate(
                  compoundAnalysis: CompoundAnalysisState, analysisId: string | undefined,
                  analysisIndex: number, details: AnalysisDetails
              ): Generator<unknown, string, any> {
                  if (analysisId) {
              Severity: Minor
              Found in client/src/compoundAnalysis/sagas.ts - About 1 hr to fix

                Function main has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def main(port, local_directory, browser, cpus, gpus, open_ds, log_level,
                         insecure, host="localhost", token_path=None, preload: tuple[str, ...] = (),
                         snooze_timeout: Optional[float] = None):
                    # Mitigation for https://stackoverflow.com/questions/71283820/
                    #   directory-parameter-on-windows-has-trailing-backslash-replaced-with-double-quote
                Severity: Minor
                Found in src/libertem/web/cli.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_resource_details has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def get_resource_details(self):
                        workers = self.get_available_workers()
                        details = {}
                
                        for worker in workers:
                Severity: Minor
                Found in src/libertem/executor/dask.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 _build_sparse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def _build_sparse(m, dtype: npt.DTypeLike, sparse_backend: SparseSupportedT, backend: ArrayBackend):
                    if sparse_backend == 'sparse.pydata' and backend == NUMPY:
                        # sparse.pydata.org is fastest for masks with few layers
                        # and few entries
                        return m.astype(dtype)
                Severity: Minor
                Found in src/libertem/common/container.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 build_mapping has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def build_mapping(el: Any,
                                  unpackable_types: dict[type, Callable[[Iterable],
                                                                        Iterable[tuple[Any, Any]]]] = None,
                                  ignore_types: Optional[tuple[type, ...]] = None,
                                  _pos: list[tuple[type, Any]] = None) -> list[list[tuple[type, Any]]]:
                Severity: Minor
                Found in src/libertem/executor/utils/delayed_unpack.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(
                        self,
                        mask_factories: Union[FactoryT, Sequence[FactoryT]],
                        dtype: Optional[npt.DTypeLike] = None,
                        use_sparse: Optional[Union[bool, SparseSupportedT]] = None,
                Severity: Minor
                Found in src/libertem/common/container.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 CenterOfMassAnalysis has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                const CenterOfMassAnalysis: React.FC<CompoundAnalysisProps> = ({ compoundAnalysis, dataset }) => {
                    const { shape } = dataset.params;
                    const [scanHeight, scanWidth, imageHeight, imageWidth] = shape;
                    const minLength = Math.min(imageWidth, imageHeight);
                    const [cx, setCx] = useState(imageWidth / 2);
                Severity: Minor
                Found in client/src/compoundAnalysis/components/CenterOfMassAnalysis.tsx - 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

                Severity
                Category
                Status
                Source
                Language