dwhswenson/contact_map

View on GitHub

Showing 28 of 68 total issues

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

    @pytest.mark.parametrize("intermediate", ["dict", "json"])
    def test_serialization_cycle(self, intermediate):
        serializer, deserializer = {
            'json': (self.map.to_json, ContactFrequency.from_json),
            'dict': (self.map.to_dict, ContactFrequency.from_dict)
Severity: Major
Found in contact_map/tests/test_contact_map.py and 1 other location - About 5 hrs to fix
contact_map/tests/test_contact_trajectory.py on lines 124..136

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

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

    @pytest.mark.parametrize("intermediate", ["dict", "json"])
    def test_serialization_cycle(self, intermediate):
        # NOTE: this is identical to TestContactFrequency; can probably
        # abstract it out
        serializer, deserializer = {
Severity: Major
Found in contact_map/tests/test_contact_trajectory.py and 1 other location - About 5 hrs to fix
contact_map/tests/test_contact_map.py on lines 427..437

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

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 contact_map.py has 786 lines of code (exceeds 750 allowed). Consider refactoring.
Confirmed

"""
Contact map analysis.
"""
# Maintainer: David W.H. Swenson (dwhs@hyperblazer.net)
# Licensed under LGPL, version 2.1 or greater
Severity: Major
Found in contact_map/contact_map.py - About 2 hrs to fix

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

        def test_dict_serialization_cycle(self, idx):
            m = self.maps[idx]
            dct = m.to_dict()
            m2 = ContactFrequency.from_dict(dct)
            _contact_object_compare(m, m2)
    Severity: Major
    Found in contact_map/tests/test_contact_map.py and 1 other location - About 2 hrs to fix
    contact_map/tests/test_contact_map.py on lines 198..203

    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

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

        def test_json_serialization_cycle(self, idx):
            m = self.maps[idx]
            json_str = m.to_json()
            m2 = ContactFrequency.from_json(json_str)
            _contact_object_compare(m, m2)
    Severity: Major
    Found in contact_map/tests/test_contact_map.py and 1 other location - About 2 hrs to fix
    contact_map/tests/test_contact_map.py on lines 191..196

    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

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

        [[0, 9], [0, 8], [1, 8], [1, 9], [1, 4], [8, 4], [8, 5], [4, 6], [4, 7],
         [5, 6], [5, 7]]
    Severity: Major
    Found in contact_map/tests/test_contact_trajectory.py and 1 other location - About 1 hr to fix
    contact_map/tests/test_contact_map.py on lines 130..131

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

    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

                self.map4: [[0, 9], [0, 8], [1, 8], [1, 9], [1, 4], [8, 4],
                            [8, 5], [4, 6], [4, 7], [5, 6], [5, 7]]
    Severity: Major
    Found in contact_map/tests/test_contact_map.py and 1 other location - About 1 hr to fix
    contact_map/tests/test_contact_trajectory.py on lines 21..22

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

    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

            (5, 3, 2, False, [(slice(0, 0), slice(0, 3), 0, 2),
                               (slice(0, 2), slice(3, 5), 2, 4)]),
    Severity: Major
    Found in contact_map/tests/test_contact_trajectory.py and 3 other locations - About 50 mins to fix
    contact_map/tests/test_contact_trajectory.py on lines 268..269
    contact_map/tests/test_contact_trajectory.py on lines 270..271
    contact_map/tests/test_contact_trajectory.py on lines 272..273

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

    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

            (6, 3, 3, False, [(slice(0, 0), slice(0, 3), 0, 2),
                              (slice(0, 3), slice(3, 6), 3, 5)]),
    Severity: Major
    Found in contact_map/tests/test_contact_trajectory.py and 3 other locations - About 50 mins to fix
    contact_map/tests/test_contact_trajectory.py on lines 261..262
    contact_map/tests/test_contact_trajectory.py on lines 268..269
    contact_map/tests/test_contact_trajectory.py on lines 272..273

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

    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

            (5, 3, 2, True, [(slice(0, 0), slice(0, 2), 0, 1),
                             (slice(0, 1), slice(2, 4), 1, 3)]),
    Severity: Major
    Found in contact_map/tests/test_contact_trajectory.py and 3 other locations - About 50 mins to fix
    contact_map/tests/test_contact_trajectory.py on lines 261..262
    contact_map/tests/test_contact_trajectory.py on lines 270..271
    contact_map/tests/test_contact_trajectory.py on lines 272..273

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

    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

            (6, 3, 3, True, [(slice(0, 0), slice(0, 3), 0, 2),
                             (slice(0, 3), slice(3, 6), 3, 5)]),
    Severity: Major
    Found in contact_map/tests/test_contact_trajectory.py and 3 other locations - About 50 mins to fix
    contact_map/tests/test_contact_trajectory.py on lines 261..262
    contact_map/tests/test_contact_trajectory.py on lines 268..269
    contact_map/tests/test_contact_trajectory.py on lines 270..271

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

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

        def to_networkx(self, weighted=True, as_index=False, graph=None):
            """Graph representation of contacts (requires networkx)
    
            Parameters
            ----------
    Severity: Minor
    Found in contact_map/contact_count.py - About 35 mins 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 _sanitize_n_x_n_y has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _sanitize_n_x_n_y(n_x, n_y, counter):
        if n_x is None and n_y is None:
            n_x, n_y = _get_sorted_counter_range(counter)
        elif n_x is None or n_y is None:
            raise ValueError("Either both n_x and n_y need to be defined or "
    Severity: Minor
    Found in contact_map/plot_utils.py - About 25 mins 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

    TODO found
    Open

          - run: |  # TODO: move this to an action

    TODO found
    Open

                # TODO: skipping compatibility checks would help performance; we
    Severity: Info
    Found in contact_map/contact_trajectory.py by fixme

    TODO found
    Open

            # TODO: better approach is to make the initialization based on
    Severity: Info
    Found in contact_map/min_dist.py by fixme

    TODO found
    Open

        # TODO: add tests for ContactObject._check_consistency

    TODO found
    Open

          - run: |  # TODO: move this to an action

    TODO found
    Open

            # TODO: this set should be made global, and everything else is based
    Severity: Info
    Found in contact_map/tests/test_min_dist.py by fixme

    TODO found
    Open

                # TODO: Might be fixable if all_atoms are equal length
    Severity: Info
    Found in contact_map/fix_parameters.py by fixme
    Severity
    Category
    Status
    Source
    Language