KarrLab/wc_lang

View on GitHub

Showing 104 of 104 total issues

File core.py has 4255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Data model to represent composite, multi-algorithmic biochemical models.

This module defines classes that represent the schema and provenance of a biochemical model:

* :obj:`Model`
Severity: Major
Found in wc_lang/core.py - About 1 wk to fix

    File util.py has 876 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """ Utilities for writing/reading a `wc_lang` model to/from SBML
    
    * Higher level functions for creating, getting, and setting SBML objects
    * Utilities for wrapping libSBML calls
    
    
    Severity: Major
    Found in wc_lang/sbml/util.py - About 2 days to fix

      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

      Function transform has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
      Open

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

      Function get_authors_annotation has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_authors_annotation(cls, model, sbml_model, model_objs):
              """ Import the SBML annotation of the authors of a model to a model
      
              Args:
                  model (:obj:`wc_lang.core.Model`): model
      Severity: Minor
      Found in wc_lang/sbml/util.py - About 6 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 37 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(self, model):
              """ Split reversible reactions in non-dFBA submodels into separate forward and backward reactions
      
              Args:
                  model (:obj:`Model`): model definition
      Severity: Minor
      Found in wc_lang/transform/split_reversible_reactions.py - About 5 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 36 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(self, obj, value, tolerance=1E-10):
              """ Determine if `value` is a valid value of the attribute
      
              Args:
                  obj (:obj:`Reaction`): object being validated
      Severity: Minor
      Found in wc_lang/core.py - About 5 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 32 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(self, path, models=None,
                  ignore_missing_models=None, ignore_extra_models=None, ignore_sheet_order=None,
                  include_all_attributes=False, ignore_missing_attributes=None, ignore_extra_attributes=None,
                  ignore_attribute_order=None, validate=None):
              """ Read a list of model objects from file(s) and, optionally, validate them
      Severity: Minor
      Found in wc_lang/io.py - About 4 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

      LibSbmlInterface has 35 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class LibSbmlInterface(object):
          ''' Methods for compactly using libSBML to create SBML objects.
      
          The libSBML method calls provide narrow interfaces, typically exchanging one
          value per call, which creates verbose code. The methods below aggregate multiple
      Severity: Minor
      Found in wc_lang/sbml/util.py - About 4 hrs to fix

        Function get_products has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_products(self, __type=None, **kwargs):
                """ Get the species produced by this objective function
        
                Args:
                    __type (:obj:`types.TypeType` or :obj:`tuple` of :obj:`types.TypeType`): subclass(es) of :obj:`Model`
        Severity: Minor
        Found in wc_lang/core.py - About 4 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 call_libsbml has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            def call_libsbml(cls, method, *args, returns_int=False, debug=False):
                """ Call a libSBML method and handle any errors.
        
                Unfortunately, libSBML methods that do not return data usually report errors via return codes,
                instead of exceptions, and the generic return codes contain virtually no information.
        Severity: Minor
        Found in wc_lang/sbml/util.py - About 4 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

        Model has 31 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Model(obj_tables.Model, SbmlModelMixin):
            """ Model
        
            Attributes:
                id (:obj:`str`): unique identifier
        Severity: Minor
        Found in wc_lang/core.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 _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

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

              class Meta:
                  label = 'create-template'
                  description = 'Create file with model template: blank file(s) with row and column labels'
                  help = 'Create file with model template: blank file(s) with row and column labels'
                  stacked_on = 'base'
          Severity: Major
          Found in wc_lang/__main__.py and 1 other location - About 3 hrs to fix
          wc_lang/__main__.py on lines 293..301

          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

              class Meta:
                  label = 'update-version-metadata'
                  description = 'Update the version metadata (repository URL, branch, revision; wc_lang version) of a model'
                  help = 'Update the version metadata (repository URL, branch, revision; wc_lang version) of a model'
                  stacked_on = 'base'
          Severity: Major
          Found in wc_lang/__main__.py and 1 other location - About 3 hrs to fix
          wc_lang/__main__.py on lines 271..279

          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 run has a Cognitive Complexity of 24 (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

                                  rxn_bck = submodel.reactions.create(
                                      model=model,
                                      id='{}_backward'.format(rxn.id),
                                      name='{} (backward)'.format(rxn.name),
                                      reversible=False,
          Severity: Major
          Found in wc_lang/transform/split_reversible_reactions.py and 1 other location - About 3 hrs to fix
          wc_lang/transform/split_reversible_reactions.py on lines 42..51

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

          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

                                  rxn_for = submodel.reactions.create(
                                      model=model,
                                      id='{}_forward'.format(rxn.id),
                                      name='{} (forward)'.format(rxn.name),
                                      reversible=False,
          Severity: Major
          Found in wc_lang/transform/split_reversible_reactions.py and 1 other location - About 3 hrs to fix
          wc_lang/transform/split_reversible_reactions.py on lines 53..62

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

          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 __main__.py has 301 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
            Severity
            Category
            Status
            Source
            Language