KarrLab/wc_lang

View on GitHub

Showing 109 of 109 total issues

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

      Function remove_metadata has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_metadata(model):
              """ Remove metadata from model
      
              Args:
                  model (:obj:`wc_utils.workbook.Workbook`): model
      Severity: Minor
      Found in wc_lang/__main__.py - About 45 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 get_errors_warnings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_errors_warnings(cls, sbml_doc):
              """ Get libSBML errors and warnings
      
              Args:
                  sbml_doc (:obj:`libsbml.SBMLDocument`): SBML document
      Severity: Minor
      Found in wc_lang/sbml/util.py - About 45 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

      Avoid deeply nested control flow statements.
      Open

                              if rxn.flux_bounds:
                                  if not math.isnan(rxn.flux_bounds.min) and not math.isnan(rxn.flux_bounds.max):
                                      # assume flux_bounds.min <= flux_bounds.max
                                      assert rxn.flux_bounds.min <= rxn.flux_bounds.max, \
                                          f"min flux bound greater than max in {rxn.id}"
      Severity: Major
      Found in wc_lang/transform/split_reversible_reactions.py - About 45 mins to fix

        Function validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self):
                """ Determine if the model is valid
        
                * Network of compartments is rooted and acyclic
                * Networks of observables and functions are acyclic
        Severity: Minor
        Found in wc_lang/core.py - About 45 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 transform has a Cognitive Complexity of 8 (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_2020_04_27.py - About 45 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

        Avoid deeply nested control flow statements.
        Open

                            if cell.value and isinstance(cell.value, str):
                                cell.value = '!' + cell.value
                else:
        Severity: Major
        Found in migrations/migration_2019_09_20.py - About 45 mins to fix

          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

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

              def get_immediate_children(self, kind=None, __type=None, __include_stop_conditions=True,
          Severity: Minor
          Found in wc_lang/core.py - About 35 mins to fix

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

                def parse_units(cls, sbml_model):
                    """ Parse SBML units to Python
            
                    Args:
                        sbml_model (:obj:`libsbml.Model`): SBML model
            Severity: Minor
            Found in wc_lang/sbml/util.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def run(cls, model):
                    """ Encode a `wc_lang` model with at most 1 submodel into SBML
            
                    * Validate model
                    * Create SBML document
            Severity: Minor
            Found in wc_lang/sbml/io.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 validate_implicit_relationships has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def validate_implicit_relationships(cls, root_model):
                    """ Check that relationships to :obj:`root_model` do not need to be explicitly exported because
                        they can be inferred by :obj:`Reader.run`. This is necessary to enable the relationships
                        to :obj:`root_model` to not be exported in workbooks, and instead added by :obj:`Reader.run`.
            
            
            Severity: Minor
            Found in wc_lang/io.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 import_relations_from_sbml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def import_relations_from_sbml(self, sbml, objs):
                    """ Load relationships from SBML compartment
            
                    Args:
                        sbml (:obj:`libsbml.Compartment`): SBML compartment
            Severity: Minor
            Found in wc_lang/core.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 __getitem__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def __getitem__(cls, name):
                    """ Get value by name
            
                    Args:
                        name (:obj:`str`): attribute name
            Severity: Minor
            Found in wc_lang/core.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