LiberTEM/LiberTEM

View on GitHub

Showing 269 of 913 total issues

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

    def validate(
        self,
        shape: tuple[int, ...],
        ds_sig_shape: tuple[int, ...],
        size: int,
Severity: Minor
Found in src/libertem/io/dataset/base/tiling_scheme.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_regression has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def get_regression(self, field: np.ndarray, valid_mask: np.ndarray):
        inp = None
        result = np.zeros((3, 2))

        com_params = self.get_params()
Severity: Minor
Found in src/libertem/udf/com.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 datasetReducer has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const datasetReducer = (state = initialDatasetState, action: AllActions): DatasetsState => {
    switch (action.type) {
        case channelActions.ActionTypes.INITIAL_STATE: {
            const datasets = action.payload.datasets.map(ds => Object.assign({}, ds, { status: DatasetStatus.OPEN }));
            return {
Severity: Minor
Found in client/src/dataset/reducers.ts - About 1 hr to fix

    Function get_view_for_frame has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_view_for_frame(self, partition, tile, frame_idx):
            """
            get a view for a single frame in a partition- or dataset-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 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_decode_r has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_decode_r(self):
            bit_depth = self._bit_depth
            layout = self._header['sensor_layout']
            num_chips = self._header['num_chips']
            if layout == (2, 2) and num_chips == 4:
    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 run_tasks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_tasks(
            self,
            tasks: Iterable[TaskProtocol],
            params_handle: Any,
            cancel_id: Any,
    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 make_local has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def make_local(cls, spec: Optional[dict] = None, cluster_kwargs: Optional[dict] = None,
                client_kwargs: Optional[dict] = None, preload: Optional[tuple[str]] = None):
            """
            Spin up a local dask cluster
    
    
    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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(self, executor: 'JobExecutor'):
            self._filesize = executor.run_function(self._get_filesize)
            array_meta = executor.run_function(self._read_metadata,
                                               self._path,
                                               use_ds=self._dm_ds_index)
    Severity: Minor
    Found in src/libertem/io/dataset/dm_single.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 _mib_2x2_tile_block has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _mib_2x2_tile_block(
        slices_arr, fileset_arr, slice_sig_sizes, sig_origins,
        inner_indices_start, inner_indices_stop, frame_indices, sig_size,
        px_to_bytes, bpp, frame_header_bytes, frame_footer_bytes, file_idxs,
        slice_offset, extra, sig_shape,
    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 correct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def correct(
            buffer, dark_image=None, gain_map=None, excluded_pixels=None, repair_descriptor=None,
            inplace=False, sig_shape=None, allow_empty=False):
        '''
        Function to perform detector corrections
    Severity: Minor
    Found in src/libertem/io/corrections/detector.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 _set_sync_offset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _set_sync_offset(self):
            self._num_frames_w_shutter_active_flag_set = _get_num_frames_w_shutter_active_flag_set(
                self._get_syncer(do_sync=False)
            )
            self._native_sync_offset = self._image_count - self._num_frames_w_shutter_active_flag_set
    Severity: Minor
    Found in src/libertem/io/dataset/k2is.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 _try_read_bitdepth has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _try_read_bitdepth(metadata: tuple[str, ...]) -> str:
            """
            Try to extract a bitdepth from the metadata items
            using the key in the post-header section of the file
            like:
    Severity: Minor
    Found in src/libertem/io/dataset/blo.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 14 arguments (exceeds 8 allowed). Consider refactoring.
    Open

        def __init__(self, tileshape=None, num_partitions=None, data=None, sig_dims=None,
    Severity: Major
    Found in src/libertem/io/dataset/memory.py - About 1 hr to fix

      Function FFTAnalysis has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

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

      Function _prepare_run_for_dataset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _prepare_run_for_dataset(
              self,
              dataset: DataSet,
              executor: JobExecutor,
              roi: Optional[np.ndarray],
      Severity: Minor
      Found in src/libertem/udf/base.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 render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public render() {
              return (
                  <Modal
                      trigger={
                          <Button
      Severity: Minor
      Found in client/src/shutdown/components/ShutdownButton.tsx - About 1 hr to fix

        Function createWebSocketChannel has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const createWebSocketChannel = (/* addr */): SocketChannel => eventChannel((emit) => {
            const onMessage = (msg: MessageEvent) => {
                if (msg.data instanceof Blob) {
                    // TODO: cleanup createObjectURL results somewhere
                    emit(channelMessages.Messages.binary(URL.createObjectURL(msg.data)));
        Severity: Minor
        Found in client/src/channel/sagas.ts - About 1 hr to fix

          Function clusterConnectionReducer has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const clusterConnectionReducer = (state: ClusterConnectionState = initialClusterConnectionState, action: AllActions): ClusterConnectionState => {
              switch (action.type) {
                  case clusterActions.ActionTypes.NOT_CONNECTED: {
                      return {
                          status: "disconnected"
          Severity: Minor
          Found in client/src/cluster/reducers.ts - About 1 hr to fix

            Function progressReducer has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const progressReducer = (state = initialProgressstate, action: AllActions): ProgressReducerState => {
                switch (action.type) {
                    case channelActions.ActionTypes.JOB_PROGRESS: {
                        switch (action.payload.details.event) {
                            case 'start':
            Severity: Minor
            Found in client/src/progress/reducers.ts - About 1 hr to fix

              Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public render(): JSX.Element {
                      const { details, style, icon } = this.props;
                      const myStyle: React.CSSProperties = {
                          cursor: "pointer",
                          ...style,
              Severity: Minor
              Found in client/src/browser/components/FileBrowserEntry.tsx - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language