KarrLab/wc_lang

View on GitHub
wc_lang/transform/merge_submodels.py

Summary

Maintainability
F
3 days
Test Coverage
A
100%

Function run has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, model):
        """ Merge groups of algorithmically-like submodels into individual submodels

        * dFBA objectives are merged by summing

Severity: Minor
Found in wc_lang/transform/merge_submodels.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

Avoid deeply nested control flow statements.
Open

                        for dfba_obj_rxn in list(submodel.dfba_obj.expression.dfba_obj_reactions):
                            submodel.dfba_obj.expression.dfba_obj_reactions.remove(dfba_obj_rxn)
                            objs_for_merged_dfba_expression[DfbaObjReaction][dfba_obj_rxn.id] = dfba_obj_rxn

Severity: Major
Found in wc_lang/transform/merge_submodels.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if submodel.dfba_obj.expression.expression:
                                merged_dfba_expression.append(submodel.dfba_obj.expression.expression)
                            for rxn in list(submodel.dfba_obj.expression.reactions):
    Severity: Major
    Found in wc_lang/transform/merge_submodels.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for rxn in list(submodel.dfba_obj.expression.reactions):
                                  submodel.dfba_obj.expression.reactions.remove(rxn)
                                  objs_for_merged_dfba_expression[Reaction][rxn.id] = rxn
                              for dfba_obj_rxn in list(submodel.dfba_obj.expression.dfba_obj_reactions):
      Severity: Major
      Found in wc_lang/transform/merge_submodels.py - About 45 mins to fix

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

                                for dfba_obj_rxn in list(submodel.dfba_obj.expression.dfba_obj_reactions):
                                    submodel.dfba_obj.expression.dfba_obj_reactions.remove(dfba_obj_rxn)
                                    objs_for_merged_dfba_expression[DfbaObjReaction][dfba_obj_rxn.id] = dfba_obj_rxn
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 1 other location - About 2 hrs to fix
        wc_lang/transform/merge_submodels.py on lines 137..139

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

        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

                                for rxn in list(submodel.dfba_obj.expression.reactions):
                                    submodel.dfba_obj.expression.reactions.remove(rxn)
                                    objs_for_merged_dfba_expression[Reaction][rxn.id] = rxn
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 1 other location - About 2 hrs to fix
        wc_lang/transform/merge_submodels.py on lines 140..142

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

        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

                            for ref in list(submodel.dfba_obj.references):
                                submodel.dfba_obj.references.remove(ref)
                                merged_submodel.dfba_obj.references.append(ref)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 3 other locations - About 1 hr to fix
        wc_lang/transform/merge_submodels.py on lines 115..117
        wc_lang/transform/merge_submodels.py on lines 119..121
        wc_lang/transform/merge_submodels.py on lines 123..125

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

        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

                            for identifier in list(submodel.dfba_obj.identifiers):
                                submodel.dfba_obj.identifiers.remove(identifier)
                                merged_submodel.dfba_obj.identifiers.append(identifier)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 3 other locations - About 1 hr to fix
        wc_lang/transform/merge_submodels.py on lines 115..117
        wc_lang/transform/merge_submodels.py on lines 119..121
        wc_lang/transform/merge_submodels.py on lines 127..129

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

        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

                            for ev in list(submodel.dfba_obj.evidence):
                                submodel.dfba_obj.evidence.remove(ev)
                                merged_submodel.dfba_obj.evidence.append(ev)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 3 other locations - About 1 hr to fix
        wc_lang/transform/merge_submodels.py on lines 119..121
        wc_lang/transform/merge_submodels.py on lines 123..125
        wc_lang/transform/merge_submodels.py on lines 127..129

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

        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

                            for conclusion in list(submodel.dfba_obj.conclusions):
                                submodel.dfba_obj.conclusions.remove(conclusion)
                                merged_submodel.dfba_obj.conclusions.append(conclusion)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 3 other locations - About 1 hr to fix
        wc_lang/transform/merge_submodels.py on lines 115..117
        wc_lang/transform/merge_submodels.py on lines 123..125
        wc_lang/transform/merge_submodels.py on lines 127..129

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

        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 6 locations. Consider refactoring.
        Open

                        for dfba_obj_rxn in list(submodel.dfba_obj_reactions):
                            submodel.dfba_obj_reactions.remove(dfba_obj_rxn)
                            merged_submodel.dfba_obj_reactions.append(dfba_obj_rxn)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 5 other locations - About 40 mins to fix
        wc_lang/transform/merge_submodels.py on lines 88..90
        wc_lang/transform/merge_submodels.py on lines 92..94
        wc_lang/transform/merge_submodels.py on lines 96..98
        wc_lang/transform/merge_submodels.py on lines 100..102
        wc_lang/transform/merge_submodels.py on lines 104..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 34.

        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 6 locations. Consider refactoring.
        Open

                        for identifier in list(submodel.identifiers):
                            submodel.identifiers.remove(identifier)
                            merged_submodel.identifiers.append(identifier)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 5 other locations - About 40 mins to fix
        wc_lang/transform/merge_submodels.py on lines 88..90
        wc_lang/transform/merge_submodels.py on lines 92..94
        wc_lang/transform/merge_submodels.py on lines 100..102
        wc_lang/transform/merge_submodels.py on lines 104..106
        wc_lang/transform/merge_submodels.py on lines 144..146

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

        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 6 locations. Consider refactoring.
        Open

                        for rxn in list(submodel.reactions):
                            submodel.reactions.remove(rxn)
                            merged_submodel.reactions.append(rxn)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 5 other locations - About 40 mins to fix
        wc_lang/transform/merge_submodels.py on lines 88..90
        wc_lang/transform/merge_submodels.py on lines 92..94
        wc_lang/transform/merge_submodels.py on lines 96..98
        wc_lang/transform/merge_submodels.py on lines 100..102
        wc_lang/transform/merge_submodels.py on lines 144..146

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

        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 6 locations. Consider refactoring.
        Open

                        for conclusion in list(submodel.conclusions):
                            submodel.conclusions.remove(conclusion)
                            merged_submodel.conclusions.append(conclusion)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 5 other locations - About 40 mins to fix
        wc_lang/transform/merge_submodels.py on lines 88..90
        wc_lang/transform/merge_submodels.py on lines 96..98
        wc_lang/transform/merge_submodels.py on lines 100..102
        wc_lang/transform/merge_submodels.py on lines 104..106
        wc_lang/transform/merge_submodels.py on lines 144..146

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

        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 6 locations. Consider refactoring.
        Open

                        for ev in list(submodel.evidence):
                            submodel.evidence.remove(ev)
                            merged_submodel.evidence.append(ev)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 5 other locations - About 40 mins to fix
        wc_lang/transform/merge_submodels.py on lines 92..94
        wc_lang/transform/merge_submodels.py on lines 96..98
        wc_lang/transform/merge_submodels.py on lines 100..102
        wc_lang/transform/merge_submodels.py on lines 104..106
        wc_lang/transform/merge_submodels.py on lines 144..146

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

        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 6 locations. Consider refactoring.
        Open

                        for ref in list(submodel.references):
                            submodel.references.remove(ref)
                            merged_submodel.references.append(ref)
        Severity: Major
        Found in wc_lang/transform/merge_submodels.py and 5 other locations - About 40 mins to fix
        wc_lang/transform/merge_submodels.py on lines 88..90
        wc_lang/transform/merge_submodels.py on lines 92..94
        wc_lang/transform/merge_submodels.py on lines 96..98
        wc_lang/transform/merge_submodels.py on lines 104..106
        wc_lang/transform/merge_submodels.py on lines 144..146

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

        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

        There are no issues that match your filters.

        Category
        Status