KarrLab/wc_lang

View on GitHub

Showing 109 of 109 total issues

File core.py has 4288 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 96 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(self, model):
              """ Split reversible reactions in 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 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 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

      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('!!'):
                  table_head_cell = ws.cell(2, 1)
                  matches = re.findall(r" +(.*?)=('((?:[^'\\]|\\.)*)'|\"((?:[^\"\\]|\\.)*)\")",
                      ws.cell(2, 1).value)
                  heading, _, _ = ws.cell(2, 1).value.partition(' ')
      Severity: Major
      Found in migrations/migration_2020_03_09.py and 1 other location - About 1 day to fix
      migrations/migration_2020_03_09.py on lines 25..32

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

      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(1, 1).value, str) and ws.cell(1, 1).value.startswith('!!'):
                  table_head_cell = ws.cell(1, 1)
                  matches = re.findall(r" +(.*?)=('((?:[^'\\]|\\.)*)'|\"((?:[^\"\\]|\\.)*)\")",
                      ws.cell(1, 1).value)
                  heading, _, _ = ws.cell(1, 1).value.partition(' ')
      Severity: Major
      Found in migrations/migration_2020_03_09.py and 1 other location - About 1 day to fix
      migrations/migration_2020_03_09.py on lines 34..41

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

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

      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 5 hrs to fix
      wc_lang/__main__.py on lines 287..298

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

      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 = '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 5 hrs to fix
      wc_lang/__main__.py on lines 311..322

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

      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 transform has a Cognitive Complexity of 33 (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_03_09.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 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

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

          class Meta:
              label = 'cut-submodels'
              description = 'Cut submodels into separate models'
              help = 'Cut submodels into separate models'
              stacked_on = 'base'
      Severity: Major
      Found in wc_lang/__main__.py and 2 other locations - About 4 hrs to fix
      wc_lang/__main__.py on lines 265..274
      wc_lang/__main__.py on lines 359..368

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

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

          class Meta:
              label = 'convert'
              description = 'Convert model among .csv, .json, .tsv, .xlsx, .yaml, and .yml formats'
              help = 'Convert model among .csv, .json, .tsv, .xlsx, .yaml, and .yml formats'
              stacked_on = 'base'
      Severity: Major
      Found in wc_lang/__main__.py and 2 other locations - About 4 hrs to fix
      wc_lang/__main__.py on lines 42..51
      wc_lang/__main__.py on lines 359..368

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

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

          class Meta:
              label = 'import'
              description = 'Import a model from SBML'
              help = 'Import a model from SBML'
              stacked_on = 'base'
      Severity: Major
      Found in wc_lang/__main__.py and 2 other locations - About 4 hrs to fix
      wc_lang/__main__.py on lines 42..51
      wc_lang/__main__.py on lines 265..274

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

      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

      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
          Severity
          Category
          Status
          Source
          Language