KarrLab/obj_tables

View on GitHub

Showing 542 of 542 total issues

Function get_related has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def get_related(self, forward=True, reverse=True):
        """ Get all related objects reachable from :obj:`self`

        Args:
            forward (:obj:`bool`, optional): if :obj:`True`, get all forward related objects
Severity: Minor
Found in obj_tables/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 serialize_to_cell has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def serialize_to_cell(self, values, encoded=None):
        """ Serialize related object

        Args:
            values (:obj:`list` of :obj:`Model`): Python representation
Severity: Minor
Found in obj_tables/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 are_attr_paths_equal has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def are_attr_paths_equal(cls, attr_path, other_attr_path):
        """ Determine if two attribute paths are semantically equal

        Args:
            attr_path (:obj:`list` of :obj:`list` of :obj:`object`):
Severity: Minor
Found in obj_tables/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

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

    def get_cls_and_model(self, id):
        """ Get the class and instance of a related model with id `id`

        Args:
            id (:obj:`str`): id
Severity: Minor
Found in obj_tables/math/expression.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 3 locations. Consider refactoring.
Open

class PbConfig(obj_tables.Model):
    option = obj_tables.StringAttribute(verbose_name='Option')
    value = obj_tables.StringAttribute(verbose_name='Value')

    class Meta(obj_tables.Model.Meta):
Severity: Major
Found in examples/sbtab/SBtab.py and 2 other locations - About 3 hrs to fix
examples/sbtab/SBtab.py on lines 1048..1059
examples/sbtab/SBtab.py on lines 1062..1073

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

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 SparseMatrixRow(obj_tables.Model):
    row_i_d = obj_tables.StringAttribute(verbose_name='RowID')
    row_string = obj_tables.StringAttribute(verbose_name='RowString')

    class Meta(obj_tables.Model.Meta):
Severity: Major
Found in examples/sbtab/SBtab.py and 2 other locations - About 3 hrs to fix
examples/sbtab/SBtab.py on lines 862..873
examples/sbtab/SBtab.py on lines 1062..1073

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

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 SparseMatrixColumn(obj_tables.Model):
    column_i_d = obj_tables.StringAttribute(verbose_name='ColumnID')
    column_string = obj_tables.StringAttribute(verbose_name='ColumnString')

    class Meta(obj_tables.Model.Meta):
Severity: Major
Found in examples/sbtab/SBtab.py and 2 other locations - About 3 hrs to fix
examples/sbtab/SBtab.py on lines 862..873
examples/sbtab/SBtab.py on lines 1048..1059

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

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 307 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Command line utilities for modeling data in tables (XLSX, CSV, TSV)

:Author: Jonathan Karr <karr@mssm.edu>
:Date: 2019-09-11
:Copyright: 2019, Karr Lab
Severity: Minor
Found in obj_tables/__main__.py - About 3 hrs to fix

    Migrator has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Migrator(object):
        """ Support schema migration
    
        Attributes:
            existing_schema (:obj:`SchemaModule`): the existing schema, and its properties
    Severity: Minor
    Found in obj_tables/migrate.py - About 3 hrs to fix

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

          def validate(cls, model_obj, parent_obj):
              """ Determine whether an expression model is valid
      
              One check eval's its deserialized expression
      
      
      Severity: Minor
      Found in obj_tables/math/expression.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 default_cleaned_value is not None and \
                      (not isinstance(default_cleaned_value, pronto.Term)
                          or default_cleaned_value not in ontology.terms()
                          or (isinstance(terms, list) and default_cleaned_value not in terms)):
                  raise ValueError(
      Severity: Major
      Found in obj_tables/sci/onto.py and 1 other location - About 3 hrs to fix
      obj_tables/sci/onto.py on lines 65..69

      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

              if default is not None and \
                      (not isinstance(default, pronto.Term)
                          or default not in ontology.terms()
                          or (isinstance(terms, list) and default not in terms)):
                  raise ValueError(
      Severity: Major
      Found in obj_tables/sci/onto.py and 1 other location - About 3 hrs to fix
      obj_tables/sci/onto.py on lines 71..75

      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

      Function _connect_models has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def _connect_models(self, existing_migrated_pairs):
              """ Connect migrated model instances
      
              Migrate :obj:`obj_tables.RelatedAttribute` connections among existing models to migrated models
      
      
      Severity: Minor
      Found in obj_tables/migrate.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 3 locations. Consider refactoring.
      Open

          class Meta:
              label = 'init-schema'
              description = 'Initialize a Python schema from a declarative description of the schema in a table (XLSX, CSV, TSV)'
              help = 'Initialize a Python schema from a declarative description of the schema in a table (XLSX, CSV, TSV)'
              stacked_on = 'base'
      Severity: Major
      Found in obj_tables/__main__.py and 2 other locations - About 3 hrs to fix
      obj_tables/__main__.py on lines 239..248
      obj_tables/__main__.py on lines 269..278

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

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

          def deserialize(self, values, objects, decoded=None):
              """ Deserialize value
      
              Args:
                  values (:obj:`object`): String representation
      Severity: Minor
      Found in obj_tables/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 3 locations. Consider refactoring.
      Open

          class Meta:
              label = 'validate'
              description = 'Validate that a workbook is consistent with a schema, and report any errors'
              help = 'Validate that a workbook is consistent with a schema, and report any errors'
              stacked_on = 'base'
      Severity: Major
      Found in obj_tables/__main__.py and 2 other locations - About 3 hrs to fix
      obj_tables/__main__.py on lines 128..137
      obj_tables/__main__.py on lines 269..278

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

      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 = 'viz-schema'
              description = 'Generate a UML diagram for a schema'
              help = 'Generate a UML diagram for a schema'
              stacked_on = 'base'
      Severity: Major
      Found in obj_tables/__main__.py and 2 other locations - About 3 hrs to fix
      obj_tables/__main__.py on lines 128..137
      obj_tables/__main__.py on lines 239..248

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

      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

          def __init__(self, default=None, none_value=None, verbose_name='', description='',
                       primary=False, unique=False, unique_case_insensitive=False):
              """
              Args:
                  default (:obj:`sympy.Symbol`, optional): default value
      Severity: Major
      Found in obj_tables/math/symbolic.py and 1 other location - About 3 hrs to fix
      obj_tables/math/symbolic.py on lines 160..172

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

      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