LiberTEM/LiberTEM

View on GitHub

Showing 902 of 903 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export default withValidation<DatasetParamsSEQ, DatasetParamsSEQForForm, DatasetInfoSEQ>({
    formToJson: (values, path) => ({
        path,
        type: DatasetTypes.SEQ,
        name: values.name,
Severity: Major
Found in client/src/dataset/components/SEQParamsForm.tsx and 3 other locations - About 1 day to fix
client/src/dataset/components/MIBParamsForm.tsx on lines 58..82
client/src/dataset/components/NPYParamsForm.tsx on lines 58..82
client/src/dataset/components/TVIPSParamsForm.tsx on lines 58..82

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 250.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export default withValidation<DatasetParamsBLO, DatasetParamsBLOForForm, DatasetInfoBLO>({
    mapPropsToValues: ({ path, initial }) => ({
        name: getInitialName("name", path, initial),
        nav_shape: adjustShapeWithBounds(getInitial("nav_shape", "", initial).toString(), "nav"),
        sig_shape: adjustShapeWithBounds(getInitial("sig_shape", "", initial).toString(), "sig"),
Severity: Major
Found in client/src/dataset/components/BLOParamsForm.tsx and 3 other locations - About 1 day to fix
client/src/dataset/components/EMPADParamsForm.tsx on lines 55..79
client/src/dataset/components/FRMS6ParamsForm.tsx on lines 55..79
client/src/dataset/components/K2ISParamsForm.tsx on lines 55..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 250.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export default withValidation<DatasetParamsEMPAD, DatasetParamsEMPADForForm, DatasetInfoEMPAD>({
    mapPropsToValues: ({ path, initial }) => ({
        name: getInitialName("name", path, initial),
        nav_shape: adjustShapeWithBounds(getInitial("nav_shape", "", initial).toString(), "nav"),
        sig_shape: adjustShapeWithBounds(getInitial("sig_shape", "", initial).toString(), "sig"),
Severity: Major
Found in client/src/dataset/components/EMPADParamsForm.tsx and 3 other locations - About 1 day to fix
client/src/dataset/components/BLOParamsForm.tsx on lines 56..81
client/src/dataset/components/FRMS6ParamsForm.tsx on lines 55..79
client/src/dataset/components/K2ISParamsForm.tsx on lines 55..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 250.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export default withValidation<DatasetParamsTVIPS, DatasetParamsTVIPSForForm, DatasetInfoTVIPS>({
    formToJson: (values, path) => ({
        path,
        type: DatasetTypes.TVIPS,
        name: values.name,
Severity: Major
Found in client/src/dataset/components/TVIPSParamsForm.tsx and 3 other locations - About 1 day to fix
client/src/dataset/components/MIBParamsForm.tsx on lines 58..82
client/src/dataset/components/NPYParamsForm.tsx on lines 58..82
client/src/dataset/components/SEQParamsForm.tsx on lines 58..82

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 250.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export default withValidation<DatasetParamsFRMS6, DatasetParamsFRMS6ForForm, DatasetInfoFRMS6>({
    mapPropsToValues: ({ path, initial }) => ({
        name: getInitialName("name", path, initial),
        nav_shape: adjustShapeWithBounds(getInitial("nav_shape", "", initial).toString(), "nav"),
        sig_shape: adjustShapeWithBounds(getInitial("sig_shape", "", initial).toString(), "sig"),
Severity: Major
Found in client/src/dataset/components/FRMS6ParamsForm.tsx and 3 other locations - About 1 day to fix
client/src/dataset/components/BLOParamsForm.tsx on lines 56..81
client/src/dataset/components/EMPADParamsForm.tsx on lines 55..79
client/src/dataset/components/K2ISParamsForm.tsx on lines 55..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 250.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

export default withValidation<DatasetParamsMIB, DatasetParamsMIBForForm, DatasetInfoMIB>({
    formToJson: (values, path) => ({
        path,
        type: DatasetTypes.MIB,
        name: values.name,
Severity: Major
Found in client/src/dataset/components/MIBParamsForm.tsx and 3 other locations - About 1 day to fix
client/src/dataset/components/NPYParamsForm.tsx on lines 58..82
client/src/dataset/components/SEQParamsForm.tsx on lines 58..82
client/src/dataset/components/TVIPSParamsForm.tsx on lines 58..82

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 250.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export default withValidation<DatasetParamsRawCSR, DatasetParamsRawCSRForForm, DatasetInfoRawCSR>({
        mapPropsToValues: ({ path, initial }) => ({
            name: getInitialName("name", path, initial),
            nav_shape: adjustShapeWithBounds(getInitial("nav_shape", "", initial).toString(), "nav"),
            sig_shape: adjustShapeWithBounds(getInitial("sig_shape", "", initial).toString(), "sig"),
    Severity: Major
    Found in client/src/dataset/components/RawCSRParamsForm.tsx and 1 other location - About 1 day to fix
    client/src/dataset/components/SERParamsForm.tsx on lines 45..67

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 230.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export default withValidation<DatasetParamsSER, DatasetParamsSERForForm, DatasetInfoSER>({
        mapPropsToValues: ({ path, initial }) => ({
            name: getInitialName("name", path, initial),
            nav_shape: adjustShapeWithBounds(getInitial("nav_shape", "", initial).toString(), "nav"),
            sig_shape: adjustShapeWithBounds(getInitial("sig_shape", "", initial).toString(), "sig"),
    Severity: Major
    Found in client/src/dataset/components/SERParamsForm.tsx and 1 other location - About 1 day to fix
    client/src/dataset/components/RawCSRParamsForm.tsx on lines 45..67

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 230.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          with api.Context() as ctx:
              ds = ctx.load(
                  "RAW",
                  path=r"C:\Users\Dieter\testfile-32-32-32-32-float32.raw",
                  nav_shape=(32, 32),
      Severity: Major
      Found in examples/digital-micrograph-local.py and 1 other location - About 1 day to fix
      examples/digital-micrograph-inline.py on lines 20..39

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 133.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

          with api.Context(executor=InlineJobExecutor()) as ctx:
              ds = ctx.load(
                  "RAW",
                  path=r"C:\Users\Dieter\testfile-32-32-32-32-float32.raw",
                  nav_shape=(32, 32),
      Severity: Major
      Found in examples/digital-micrograph-inline.py and 1 other location - About 1 day to fix
      examples/digital-micrograph-local.py on lines 29..48

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 133.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                const frameViewHandlesreal: HandleRenderFunction = (handleDragStart, handleDrop) => (<>
                    <DraggableHandle x={realCenterX} y={realCenterY}
                        imageWidth={imageWidth}
                        onDragMove={handleCenterChange}
                        parentOnDragStart={handleDragStart}
            Severity: Major
            Found in client/src/compoundAnalysis/components/FFTAnalysis.tsx and 2 other locations - About 6 hrs to fix
            client/src/compoundAnalysis/components/DiskMaskAnalysis.tsx on lines 36..49
            client/src/compoundAnalysis/components/roi/DiskROI.tsx on lines 43..56

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 161.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                const diskRoiHandles: HandleRenderFunction = (handleDragStart, handleDrop) => (<>
                    <DraggableHandle x={cx} y={cy}
                        imageWidth={scanWidth}
                        onDragMove={handleCenterChange}
                        parentOnDragStart={handleDragStart}
            Severity: Major
            Found in client/src/compoundAnalysis/components/roi/DiskROI.tsx and 2 other locations - About 6 hrs to fix
            client/src/compoundAnalysis/components/DiskMaskAnalysis.tsx on lines 36..49
            client/src/compoundAnalysis/components/FFTAnalysis.tsx on lines 87..100

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 161.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language