LiberTEM/LiberTEM

View on GitHub

Showing 491 of 903 total issues

File base.py has 2244 lines of code (exceeds 400 allowed). Consider refactoring.
Open

from collections import defaultdict, OrderedDict
from contextlib import contextmanager
import typing
from typing import (
    Any, Optional,
Severity: Major
Found in src/libertem/udf/base.py - About 5 days to fix

    File api.py has 1483 lines of code (exceeds 400 allowed). Consider refactoring.
    Open

    from typing import (
        TYPE_CHECKING, Any, Optional, Union, overload
    )
    from collections.abc import Iterable, Generator, Coroutine
    from typing_extensions import Literal
    Severity: Major
    Found in src/libertem/api.py - About 3 days to fix

      File pipelined.py has 1005 lines of code (exceeds 400 allowed). Consider refactoring.
      Open

      import itertools
      import os
      import sys
      import logging
      import functools
      Severity: Major
      Found in src/libertem/executor/pipelined.py - About 2 days to fix

        File mib.py has 1005 lines of code (exceeds 400 allowed). Consider refactoring.
        Open

        import re
        import os
        import platform
        from glob import glob, escape
        import logging
        Severity: Major
        Found in src/libertem/io/dataset/mib.py - About 2 days to fix

          File k2is.py has 849 lines of code (exceeds 400 allowed). Consider refactoring.
          Open

          import os
          import re
          import glob
          import math
          import typing
          Severity: Major
          Found in src/libertem/io/dataset/k2is.py - About 1 day to fix

            File buffers.py has 825 lines of code (exceeds 400 allowed). Consider refactoring.
            Open

            from typing import Any, Optional, Union, TYPE_CHECKING, Generic, TypeVar
            from collections.abc import Iterable
            from typing_extensions import Literal
            import mmap
            import math
            Severity: Major
            Found in src/libertem/common/buffers.py - About 1 day to fix

              Function _execution_plan has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
              Open

              def _execution_plan(
                  udfs, ds: Union[DataSet, DataSetMeta], device_class: Optional[DeviceClass] = None,
                  available_backends: Iterable[ArrayBackend] = BACKENDS
              ) -> tuple[ArrayBackend, ExecutionPlan]:
                  '''
              Severity: Minor
              Found in src/libertem/udf/base.py - About 1 day 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 hdf5.py has 729 lines of code (exceeds 400 allowed). Consider refactoring.
              Open

              import os
              import contextlib
              import typing
              from typing import Optional
              import warnings
              Severity: Major
              Found in src/libertem/io/dataset/hdf5.py - About 1 day to fix

                Function DatasetOpen has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
                Open

                const DatasetOpen = () => {
                    const dispatch = useDispatch();
                    const openState = useSelector((state: RootReducer) => state.openDataset);
                
                    const [didReset, setReset] = React.useState(false);
                Severity: Minor
                Found in client/src/dataset/components/DatasetOpen.tsx - About 1 day 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 693 lines of code (exceeds 400 allowed). Consider refactoring.
                Open

                import os
                import contextlib
                from copy import deepcopy
                import functools
                import logging
                Severity: Major
                Found in src/libertem/executor/dask.py - About 1 day to fix

                  File messages.ts has 609 lines of code (exceeds 400 allowed). Consider refactoring.
                  Open

                  import { JobList } from "./analysis/types"
                  
                  /*
                   * Common
                   */
                  Severity: Major
                  Found in client/src/messages.ts - About 7 hrs to fix

                    Function _correct_numba_inplace has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def _correct_numba_inplace(buffer, dark_image, gain_map, exclude_pixels, repair_environments,
                            repair_counts):
                        '''
                        Numerical work horse to perform detector corrections
                    
                    
                    Severity: Minor
                    Found in src/libertem/io/corrections/detector.py - About 6 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 frms6.py has 596 lines of code (exceeds 400 allowed). Consider refactoring.
                    Open

                    import os
                    import re
                    import csv
                    from glob import glob, escape
                    import typing
                    Severity: Major
                    Found in src/libertem/io/dataset/frms6.py - About 6 hrs to fix

                      File com.py has 595 lines of code (exceeds 400 allowed). Consider refactoring.
                      Open

                      from enum import IntEnum
                      from typing import NamedTuple, Optional, Union
                      from typing_extensions import Literal
                      
                      import numpy as np
                      Severity: Major
                      Found in src/libertem/udf/com.py - About 6 hrs to fix

                        File executor.py has 567 lines of code (exceeds 400 allowed). Consider refactoring.
                        Open

                        import queue
                        from typing import (
                            Callable, Optional, Any, TYPE_CHECKING,
                            TypeVar,
                        )
                        Severity: Major
                        Found in src/libertem/common/executor.py - About 6 hrs to fix

                          File seq.py has 565 lines of code (exceeds 400 allowed). Consider refactoring.
                          Open

                          # Based on the SEQ reader of the PIMS project, with the following license:
                          #
                          #    Copyright (c) 2013-2014 PIMS contributors
                          #    https://github.com/soft-matter/pims
                          #    All rights reserved
                          Severity: Major
                          Found in src/libertem/io/dataset/seq.py - About 5 hrs to fix

                            Cyclomatic complexity is too high in method sync_sectors. (30)
                            Open

                                def sync_sectors(self):
                                    for b in self.first_blocks():
                                        assert b.is_valid, "first block is not valid!"
                                    # sync up all sectors to start with the same `block_count`
                                    block_with_max_idx = sorted(self.first_blocks(), key=lambda b: b.header['block_count'])[-1]
                            Severity: Minor
                            Found in src/libertem/io/dataset/k2is.py by radon

                            Cyclomatic Complexity

                            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                            Construct Effect on CC Reasoning
                            if +1 An if statement is a single decision.
                            elif +1 The elif statement adds another decision.
                            else +0 The else statement does not cause a new decision. The decision is at the if.
                            for +1 There is a decision at the start of the loop.
                            while +1 There is a decision at the while statement.
                            except +1 Each except branch adds a new conditional path of execution.
                            finally +0 The finally block is unconditionally executed.
                            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                            assert +1 The assert statement internally roughly equals a conditional statement.
                            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                            Source: http://radon.readthedocs.org/en/latest/intro.html

                            Cyclomatic complexity is too high in function worker_loop. (24)
                            Open

                            def worker_loop(
                                queues: WorkerQueues,
                                work_mem: dict,
                                worker_idx: int,
                                env: Environment
                            Severity: Minor
                            Found in src/libertem/executor/pipelined.py by radon

                            Cyclomatic Complexity

                            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                            Construct Effect on CC Reasoning
                            if +1 An if statement is a single decision.
                            elif +1 The elif statement adds another decision.
                            else +0 The else statement does not cause a new decision. The decision is at the if.
                            for +1 There is a decision at the start of the loop.
                            while +1 There is a decision at the while statement.
                            except +1 Each except branch adds a new conditional path of execution.
                            finally +0 The finally block is unconditionally executed.
                            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                            assert +1 The assert statement internally roughly equals a conditional statement.
                            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                            Source: http://radon.readthedocs.org/en/latest/intro.html

                            Function radial_bins has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def radial_bins(centerX, centerY, imageSizeX, imageSizeY,
                                    radius=None, radius_inner=0, n_bins=None, normalize=False, use_sparse=None, dtype=None):
                                '''
                                Generate antialiased rings
                                '''
                            Severity: Minor
                            Found in src/libertem/masks.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

                            Cyclomatic complexity is too high in method _adapt_chunking. (23)
                            Open

                                def _adapt_chunking(self, array, sig_dims):
                                    n_dimension = array.ndim
                                    # Handle chunked signal dimensions by merging just in case
                                    sig_dim_idxs = [*range(n_dimension)[-sig_dims:]]
                                    if any([len(array.chunks[c]) > 1 for c in sig_dim_idxs]):
                            Severity: Minor
                            Found in src/libertem/io/dataset/dask.py by radon

                            Cyclomatic Complexity

                            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                            Construct Effect on CC Reasoning
                            if +1 An if statement is a single decision.
                            elif +1 The elif statement adds another decision.
                            else +0 The else statement does not cause a new decision. The decision is at the if.
                            for +1 There is a decision at the start of the loop.
                            while +1 There is a decision at the while statement.
                            except +1 Each except branch adds a new conditional path of execution.
                            finally +0 The finally block is unconditionally executed.
                            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                            assert +1 The assert statement internally roughly equals a conditional statement.
                            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                            Source: http://radon.readthedocs.org/en/latest/intro.html

                            Severity
                            Category
                            Status
                            Source
                            Language