KarrLab/wc_analysis

View on GitHub

Showing 11 of 11 total issues

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

            for participant in rxn.participants:
                part = participant.species
                if participant.coefficient < 0:
                    # reactant
                    digraph.add_edge(part, rxn)
Severity: Major
Found in wc_analysis/model/fba.py and 1 other location - About 2 hrs to fix
wc_analysis/model/fba.py on lines 178..186

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

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

            if rxn.reversible:
                for participant in rxn.participants:
                    part = participant.species
                    if participant.coefficient < 0:
                        # product
Severity: Major
Found in wc_analysis/model/fba.py and 1 other location - About 2 hrs to fix
wc_analysis/model/fba.py on lines 170..177

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

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

    def get_digraph(self, submodel):
        """ Create a NetworkX network representing the reaction network in `submodel`

        To leverage the algorithms in NetworkX, map a reaction network on to a NetworkX
        directed graph.
Severity: Minor
Found in wc_analysis/model/fba.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 unbounded_paths has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def unbounded_paths(self, rxn_network, ex_species, obj_fn_species, min_non_finite_ub=1000.0):
        """ Find the unbounded paths from an extracellular species to some objective function species

        Return all paths in a reaction network that lack a finite flux upper bound
        and go from `ex_species` to an objective function component.
Severity: Minor
Found in wc_analysis/model/fba.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_dead_end_species has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def get_dead_end_species(self, submodel, inactive_reactions):
        """ Find the dead end species in a reaction network

        Given a set of inactive reactions in submodel, determine species that are not consumed by
        any reaction, or are not produced by any reaction. Costs :math:`O(n*p)`, where :math:`n` is
Severity: Minor
Found in wc_analysis/model/fba.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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self):
        """ Run multiple analyses

        Raises:
            :obj:`ValueError`: if the analysis is not supported
Severity: Minor
Found in wc_analysis/core.py - About 55 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, knowledge_base=None, model=None, sim_results_path=None,
Severity: Minor
Found in wc_analysis/core.py - About 45 mins to fix

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

                if not isinstance(of_specie, wc_lang.Species):
                    raise ValueError("elements of 'obj_fn_species' should be wc_lang.Species instances, but one is a {}".format(
                        type(of_specie).__name__))
    Severity: Minor
    Found in wc_analysis/model/fba.py and 1 other location - About 40 mins to fix
    wc_analysis/model/fba.py on lines 250..252

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

            if not isinstance(ex_species, wc_lang.Species):
                raise ValueError("'ex_species' should be a wc_lang.Species instance, but it is a {}".format(
                    type(ex_species).__name__))
    Severity: Minor
    Found in wc_analysis/model/fba.py and 1 other location - About 40 mins to fix
    wc_analysis/model/fba.py on lines 254..256

    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

    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, sim_results_path, model=None, knowledge_base=None, out_path=None, options=None):
    Severity: Minor
    Found in wc_analysis/core.py - About 35 mins to fix

      Function get_inactive_rxns has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_inactive_rxns(self, submodel, dead_end_species):
              """ Find the inactive reactions in a reaction network
      
              Given the dead end species in a reaction network, find the reactions that must eventually
              become inactive. Reactions that consume species which are not produced must become inactive.
      Severity: Minor
      Found in wc_analysis/model/fba.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

      Severity
      Category
      Status
      Source
      Language