CellProfiler/centrosome

View on GitHub

Showing 380 of 380 total issues

Function convex_hull_transform has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def convex_hull_transform(
    image, levels=256, mask=None, chunksize=CONVEX_HULL_CHUNKSIZE, pass_cutoff=16
):
    """Perform the convex hull transform of this image

Severity: Major
Found in centrosome/filter.py - About 2 hrs to fix

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

            first = np.hstack([[True], (i[:-1] != i[1:]) | (j[:-1] != j[1:])])
    Severity: Major
    Found in centrosome/cpmorphology.py and 1 other location - About 2 hrs to fix
    centrosome/cpmorphology.py on lines 100..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 58.

    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

            first = np.hstack([[True], (i[:-1] != i[1:]) | (j[:-1] != j[1:])])
    Severity: Major
    Found in centrosome/cpmorphology.py and 1 other location - About 2 hrs to fix
    centrosome/cpmorphology.py on lines 106..106

    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 58.

    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 get_threshold has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_threshold(
        threshold_method,
        threshold_modifier,
        image,
        mask=None,
    Severity: Minor
    Found in centrosome/threshold.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

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

            binary_shrink_top_right = make_table(
                False,
                np.array([[0, 0, 0], [0, 1, 0], [0, 1, 0]], bool),
                np.array([[1, 1, 1], [0, 1, 0], [0, 1, 0]], bool),
    Severity: Major
    Found in centrosome/cpmorphology.py and 1 other location - About 2 hrs to fix
    centrosome/cpmorphology.py on lines 267..270

    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 57.

    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 backgr has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def backgr(
        img,
        mask=None,
        mode=MODE_AUTO,
        thresh=2,
    Severity: Minor
    Found in centrosome/bg_compensate.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 regional_maximum has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def regional_maximum(image, mask=None, structure=None, ties_are_ok=False):
        """Return a binary mask containing only points that are regional maxima
        
        image     - image to be transformed
        mask      - mask of relevant pixels
    Severity: Minor
    Found in centrosome/cpmorphology.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

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

            binary_shrink_bottom_left = make_table(
                False,
                np.array([[0, 1, 0], [0, 1, 0], [0, 0, 0]], bool),
                np.array([[0, 1, 0], [0, 1, 0], [1, 1, 1]], bool),
    Severity: Major
    Found in centrosome/cpmorphology.py and 1 other location - About 2 hrs to fix
    centrosome/cpmorphology.py on lines 231..234

    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 57.

    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 fill_labeled_holes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def fill_labeled_holes(labels, mask=None, size_fn=None):
        """Fill all background pixels that are holes inside the foreground
     
        A pixel is a hole inside a foreground object if
        
    Severity: Minor
    Found in centrosome/cpmorphology.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

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

            (l0[:, 0] - l1[:, 0]) * (l0[:, 1] - pt[:, 1])
            - (l0[:, 0] - pt[:, 0]) * (l0[:, 1] - l1[:, 1])
    Severity: Major
    Found in centrosome/cpmorphology.py and 1 other location - About 2 hrs to fix
    centrosome/cpmorphology.py on lines 2136..2136

    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 55.

    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 table_lookup has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def table_lookup(image, table, border_value, iterations=None):
        """Perform a morphological transform on an image, directed by its neighbors
        
        image - a binary image
        table - a 512-element table giving the transform of each pixel given
    Severity: Minor
    Found in centrosome/cpmorphology.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 euler_number has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def euler_number(labels, indexes=None):
        """Calculate the Euler number of each label
        
        labels - a label matrix
        indexes - the indexes of the labels to measure or None to
    Severity: Major
    Found in centrosome/cpmorphology.py - About 2 hrs to fix

      Function feret_diameter has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def feret_diameter(chulls, counts, indexes):
          """Return the minimum and maximum Feret diameter for each object
          
          This function takes the convex hull data, as generated by convex_hull
          and returns the minimum and maximum Feret diameter for each convex hull.
      Severity: Major
      Found in centrosome/cpmorphology.py - About 2 hrs to fix

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

            | make_table(
                True,
                np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0]]),
                np.array([[0, 0, 0], [1, 1, 0], [1, 1, 0]]),
        Severity: Major
        Found in centrosome/cpmorphology.py and 3 other locations - About 2 hrs to fix
        centrosome/cpmorphology.py on lines 3535..3538
        centrosome/cpmorphology.py on lines 3530..3533
        centrosome/cpmorphology.py on lines 3520..3528

        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 51.

        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

            | make_table(
                True,
                np.array([[0, 1, 0], [0, 0, 1], [0, 0, 0]]),
                np.array([[0, 1, 1], [0, 1, 1], [0, 0, 0]]),
        Severity: Major
        Found in centrosome/cpmorphology.py and 3 other locations - About 2 hrs to fix
        centrosome/cpmorphology.py on lines 3540..3543
        centrosome/cpmorphology.py on lines 3535..3538
        centrosome/cpmorphology.py on lines 3520..3528

        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 51.

        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 draw_line has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def draw_line(labels, pt0, pt1, value=1):
            """Draw a line between two points
            
            pt0, pt1 are in i,j format which is the reverse of x,y format
            Uses the Bresenham algorithm
        Severity: Minor
        Found in centrosome/cpmorphology.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 convex_hull_transform has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def convex_hull_transform(
            image, levels=256, mask=None, chunksize=CONVEX_HULL_CHUNKSIZE, pass_cutoff=16
        ):
            """Perform the convex hull transform of this image
        
        
        Severity: Minor
        Found in centrosome/filter.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_mog_threshold has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_mog_threshold(image, mask=None, object_fraction=0.2):
            """Compute a background using a mixture of gaussians
            
            This function finds a suitable
            threshold for the input image Block. It assumes that the pixels in the
        Severity: Minor
        Found in centrosome/threshold.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

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

            | make_table(
                True,
                np.array([[0, 0, 0], [0, 0, 1], [0, 1, 0]]),
                np.array([[0, 0, 0], [0, 1, 1], [0, 1, 1]]),
        Severity: Major
        Found in centrosome/cpmorphology.py and 3 other locations - About 2 hrs to fix
        centrosome/cpmorphology.py on lines 3540..3543
        centrosome/cpmorphology.py on lines 3530..3533
        centrosome/cpmorphology.py on lines 3520..3528

        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 51.

        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

            make_table(
                True,
                np.array([[0, 0, 0], [0, 1, 0], [0, 0, 0]], bool),
                np.array([[0, 0, 0], [0, 1, 0], [0, 0, 0]], bool),
            )
        Severity: Major
        Found in centrosome/cpmorphology.py and 3 other locations - About 2 hrs to fix
        centrosome/cpmorphology.py on lines 3540..3543
        centrosome/cpmorphology.py on lines 3535..3538
        centrosome/cpmorphology.py on lines 3530..3533

        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 51.

        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