KarrLab/wc_lang

View on GitHub

Showing 109 of 109 total issues

File __main__.py has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Command line programs for manipulating model definitions

:Author: Jonathan Karr <karr@mssm.edu>
:Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu>
:Date: 2016-12-07
Severity: Minor
Found in wc_lang/__main__.py - About 3 hrs to fix

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

        def run(self, model):
            """ Transform model
    
            Args:
                model (:obj:`Model`): model
    Severity: Minor
    Found in wc_lang/transform/set_finite_dfba_flux_bounds.py - About 3 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 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, model):
            """ Create implicit exchange reactions for dFBA submodels
    
            Args:
                model (:obj:`Model`): model
    Severity: Minor
    Found in wc_lang/transform/create_implicit_dfba_ex_rxns.py - About 3 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

            if isinstance(ws.cell(1, 1).value, str) and ws.cell(1, 1).value.startswith('!!'):
                ws.cell(1, 1).value = re.sub(r" +id=('((?:[^'\\]|\\.)*)'|\"((?:[^\"\\]|\\.)*)\")", r" class=\1",
                                             ws.cell(1, 1).value)
    Severity: Major
    Found in migrations/migration_2020_04_27.py and 1 other location - About 3 hrs to fix
    migrations/migration_2020_04_27.py on lines 25..27

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

    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 isinstance(ws.cell(2, 1).value, str) and ws.cell(2, 1).value.startswith('!!'):
                ws.cell(2, 1).value = re.sub(r" +id=('((?:[^'\\]|\\.)*)'|\"((?:[^\"\\]|\\.)*)\")", r" class=\1",
                                             ws.cell(2, 1).value)
    Severity: Major
    Found in migrations/migration_2020_04_27.py and 1 other location - About 3 hrs to fix
    migrations/migration_2020_04_27.py on lines 21..23

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

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

        def _get_cyclic_deps(self):
            """ Verify that the networks of depencencies for observables and functions are acyclic
    
            Returns:
                :obj:`dict`: dictionary of dictionary of lists of objects with cyclic dependencies,
    Severity: Minor
    Found in wc_lang/core.py - About 3 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 validate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self):
            """ Check that the structure is valid
    
            * Format provided when structure is not None
            * Value provided when format is not None
    Severity: Minor
    Found in wc_lang/core.py - About 3 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 import_from_sbml has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_from_sbml(self, sbml_rxn):
            """ Load from SBML reaction
    
            Args:
                sbml (:obj:`libsbml.Reaction`): SBML reaction
    Severity: Minor
    Found in wc_lang/core.py - About 3 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 transform has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def transform(filename):
        # read
        wb = openpyxl.load_workbook(filename=filename)
    
        for ws in wb:
    Severity: Minor
    Found in migrations/migration_2019_10_10.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

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

                    for i_col in range(n_head_rows):
                        cell = ws.cell(i_row + 2, i_col + 1)
                        if cell.value and isinstance(cell.value, str):
                            cell.value = '!' + cell.value
    Severity: Major
    Found in migrations/migration_2019_09_20.py and 1 other location - About 2 hrs to fix
    migrations/migration_2019_09_20.py on lines 69..72

    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

                    for i_col in range(ws.max_column):
                        cell = ws.cell(i_row + 2, i_col + 1)
                        if cell.value and isinstance(cell.value, str):
                            cell.value = '!' + cell.value
    Severity: Major
    Found in migrations/migration_2019_09_20.py and 1 other location - About 2 hrs to fix
    migrations/migration_2019_09_20.py on lines 75..78

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

            def gbl(self, *args):
                parts = []
                for arg in args:
                    if isinstance(arg, lark.lexer.Token) and \
                            arg.type == 'SPECIES_COEFFICIENT__SPECIES__COMPARTMENT__ID':
    Severity: Minor
    Found in wc_lang/core.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 validate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self):
            """ Determine whether this `RateLaw` is valid
    
            * Check if identifier equal to `{reaction.id}-{direction.name}`
    
    
    Severity: Minor
    Found in wc_lang/core.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 validate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self):
            """ Check if the reaction is valid
    
            * If the submodel is ODE or SSA, check that the reaction has a forward rate law
            * If the submodel is ODE or SSA and the reaction is reversible, check that the reaction has a
    Severity: Minor
    Found in wc_lang/core.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_immediate_children has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_immediate_children(self, kind=None, __type=None, __include_stop_conditions=True,
                                   **kwargs):
            """ Get a kind of children.
    
            If :obj:`kind` is :obj:`None`, children are defined to be the values of the related attributes defined
    Severity: Minor
    Found in wc_lang/core.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

                        if rxn.flux_bounds.max is None or isnan(rxn.flux_bounds.max):
                            rxn.flux_bounds.max = flux_max
                        else:
                            rxn.flux_bounds.max = min(rxn.flux_bounds.max, flux_max)
    Severity: Major
    Found in wc_lang/transform/set_finite_dfba_flux_bounds.py and 1 other location - About 2 hrs to fix
    wc_lang/transform/set_finite_dfba_flux_bounds.py on lines 70..73

    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

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

                        if rxn.flux_bounds.min is None or isnan(rxn.flux_bounds.min):
                            rxn.flux_bounds.min = flux_min
                        else:
                            rxn.flux_bounds.min = max(rxn.flux_bounds.min, flux_min)
    Severity: Major
    Found in wc_lang/transform/set_finite_dfba_flux_bounds.py and 1 other location - About 2 hrs to fix
    wc_lang/transform/set_finite_dfba_flux_bounds.py on lines 75..78

    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 run has 18 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def run(self, path, model, models=None, get_related=True, include_all_attributes=False, validate=None,
    Severity: Major
    Found in wc_lang/io.py - About 2 hrs to fix

      Function parse_annotations has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_annotations(cls, sbml_obj):
              """ Import annotations from a model object to an SBML object
      
              Args:
                  sbml_obj (:obj:`libsbml.SBase`): SBML object
      Severity: Minor
      Found in wc_lang/sbml/util.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

                              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

      Severity
      Category
      Status
      Source
      Language