KarrLab/obj_tables

View on GitHub
obj_tables/migrate.py

Summary

Maintainability
F
2 wks
Test Coverage
A
91%

File migrate.py has 2830 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Support schema migration

:Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu>
:Date: 2018-11-18
:Copyright: 2018, Karr Lab
Severity: Major
Found in obj_tables/migrate.py - About 1 wk to fix

    Function import_module_for_migration has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_module_for_migration(self, validate=True, required_attrs=None, debug=False,
                                        mod_patterns=None, print_code=False):
            """ Import a schema from a Python module in a file, which may be in a package
    
            Args:
    Severity: Minor
    Found in obj_tables/migrate.py - About 2 days 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 57 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self):
            """ Validate the attributes of a migration specification
    
            Returns:
                :obj:`list` of :obj:`str`: list of errors found
    Severity: Minor
    Found in obj_tables/migrate.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_inconsistencies has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_inconsistencies(self, existing_model, migrated_model):
            """ Detect inconsistencies between `existing_model` and `migrated_model` model classes
    
            Detect inconsistencies between `existing_model` and `migrated_model`. Inconsistencies arise if the loaded `existing_model`
            or `migrated_model` definitions are not consistent with their model or attribute renaming specifications
    Severity: Minor
    Found in obj_tables/migrate.py - About 7 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 find_schema_modules has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_schema_modules():
            """ Find the modules used by a schema
    
            Useful for creating schema changes files for a schema repo
    
    
    Severity: Minor
    Found in obj_tables/migrate.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

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

      Function standardize has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def standardize(self):
              """ Standardize the attributes of a :obj:`MigrationSpec`
      
              In particular, standardize a :obj:`MigrationSpec` that has been read from a YAML config file
              """
      Severity: Minor
      Found in obj_tables/migrate.py - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def validate(schema_changes_kwargs):
              """ Check that the attributes of the arguments to :obj:`SchemaChanges` have the right structure
      
              Args:
                  schema_changes_kwargs (:obj:`dict`): kwargs arguments to :obj:`SchemaChanges` generated by loading a schema
      Severity: Minor
      Found in obj_tables/migrate.py - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      GitRepo has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class GitRepo(object):
          """ Methods for processing a git repo and its commit history
      
          Attributes:
              repo_dir (:obj:`str`): the repo's root directory
      Severity: Minor
      Found in obj_tables/migrate.py - About 2 hrs to fix

        Function _validate_renamed_models has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def _validate_renamed_models(self):
                """ Validate renamed models
        
                Ensure that renamed models:
        
        
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr 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 _migrate_expression has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def _migrate_expression(self, existing_analyzed_expr):
                """ Migrate a model instance's :obj:`ParsedExpression.expression`
        
                The :obj:`ParsedExpression` syntax supports model type names in a Name.model_id notation.
                If a model type name changes then these must be migrated.
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr 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_renamed_attrs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _validate_renamed_attrs(self):
                """ Validate renamed attributes
        
                Ensure that renamed attributes:
        
        
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr 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 __str__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def __str__(self):
                """ Provide a string representation
        
                Returns:
                    :obj:`str`: a string representation of this `GitRepo`
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr 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 _migrate_model has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _migrate_model(self, existing_model, existing_model_def, migrated_model_def):
                """ Migrate a model instance's non-related attributes
        
                Args:
                    existing_model (:obj:`obj_tables.Model`): an existing model instance
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr 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 load_config_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_config_file(data_schema_migration_conf_file):
                """ Load a data-schema migration config file
        
                Args:
                    data_schema_migration_conf_file (:obj:`str`): path to the data-schema migration config file
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr 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 _check_imported_models has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def _check_imported_models(self, module=None):
                """ Check consistency of an imported module
        
                Args:
                    module (:obj:`Module`, optional): a `Module` containing subclasses of `obj_tables.Model`;
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr 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 make_data_schema_migration_conf_file_cmd has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def make_data_schema_migration_conf_file_cmd(data_repo_dir, schema_file_url, files_to_migrate,
                                                         add_to_repo=True):
                """ Make a data-schema migration configuration file from CLI input
        
                Args:
        Severity: Minor
        Found in obj_tables/migrate.py - About 1 hr to fix

          Function migrate_over_schema_sequence has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def migrate_over_schema_sequence(migration_spec):
                  """ Migrate some model files over a sequence of schemas
          
                  Args:
                      migration_spec (:obj:`MigrationSpec`): a migration specification
          Severity: Minor
          Found in obj_tables/migrate.py - About 1 hr 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 _migrate_all_analyzed_exprs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def _migrate_all_analyzed_exprs(self, all_models):
                  """ Migrate all model instances' :obj:`ParsedExpression`\ s
          
                  This must be done after all migrated models have been created.
          
          
          Severity: Minor
          Found in obj_tables/migrate.py - About 1 hr 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_custom_IO_classes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def import_custom_IO_classes(self, io_classes_file_basename=None):
                  """ If the schema repo has an IO classes file, import custom IO classes for accessing data files
          
                  Args:
                      io_classes_file_basename (:obj:`str`, optional): custom basename for the custom IO classes file,
          Severity: Minor
          Found in obj_tables/migrate.py - About 55 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 automated_migrate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def automated_migrate(self, tmp_dir=None):
                  """ Migrate the *data* repo's data files
          
                  Migrate to the latest commit referenced by a schema changes file in the *schema* repo, and
                  migrate data files in place.
          Severity: Minor
          Found in obj_tables/migrate.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, schema_repo=None, schema_changes_file=None, commit_hash=None, renamed_models=None,
          Severity: Minor
          Found in obj_tables/migrate.py - About 45 mins to fix

            Function write_migrated_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def write_migrated_file(self, migrated_models, model_order, existing_file, migrated_file=None,
            Severity: Minor
            Found in obj_tables/migrate.py - About 45 mins to fix

              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, existing_defs_file=None, migrated_defs_file=None, renamed_models=None,
              Severity: Minor
              Found in obj_tables/migrate.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if len(pair) != 2 or not isinstance(pair[0], str) or not isinstance(pair[1], str):
                                                errors.append(required_structure)
                            except TypeError as e:
                Severity: Major
                Found in obj_tables/migrate.py - About 45 mins to fix

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

                      def _get_model_defs(self, module):
                          """ Obtain the `obj_tables.Model`\ s in a module
                  
                          Args:
                              module (:obj:`Module`): a `Module` containing subclasses of `obj_tables.Model`
                  Severity: Minor
                  Found in obj_tables/migrate.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

                                          for model in val:
                                              migrated_val.append(getattr(model, self._migrated_copy_attr_name))
                                      else:
                  Severity: Major
                  Found in obj_tables/migrate.py - About 45 mins to fix

                    Function _write has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def _write(self, existing_file, migrated_models, schema_metadata_model=None, migrated_file=None,
                    Severity: Minor
                    Found in obj_tables/migrate.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if existing_rel_attr != migrated_rel_attr:
                                                  inconsistencies.append("{}.{}.{} is '{}', which differs from the migrated value "
                                                                         "of {}.{}.{}, which is '{}'".format(
                                                                             existing_model, existing_attr_name, rel_attr,
                                                                             existing_rel_attr, migrated_class, migrated_attr, rel_attr, migrated_rel_attr))
                      Severity: Major
                      Found in obj_tables/migrate.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if compiled_mod_pattern.search(name):
                                                    if hasattr(module, '__file__'):
                                                        print('\t', name, module.__file__)
                                                    else:
                                                        print('\t', name)
                        Severity: Major
                        Found in obj_tables/migrate.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if existing_rel_attr_name in self.deleted_models:
                                                      inconsistencies.append("existing model '{}' is not migrated, "
                                                                             "but is referenced by migrated attribute {}.{}".format(existing_rel_attr_name,
                                                                                                                                    migrated_class, migrated_attr))
                                                  else:
                          Severity: Major
                          Found in obj_tables/migrate.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if os.path.isfile(path):
                                                        print_file(path)
                                            self.module_name, self.directory
                            Severity: Major
                            Found in obj_tables/migrate.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          for attr_spec in attribute_renaming:
                                                              if len(attr_spec) != 2 or not isinstance(attr_spec[0], str) or \
                                                                      not isinstance(attr_spec[1], str):
                                                                  errors.append(required_structure)
                                          except TypeError as e:
                              Severity: Major
                              Found in obj_tables/migrate.py - About 45 mins to fix

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

                                    def import_module_for_migration(self, validate=True, required_attrs=None, debug=False,
                                Severity: Minor
                                Found in obj_tables/migrate.py - About 35 mins to fix

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

                                      def make_template(self, schema_url=None, commit_hash=None):
                                          """ Make a template schema changes file
                                  
                                          The template includes the repo hash which it describes and empty values for :obj:`SchemaChanges`
                                          attributes.
                                  Severity: Minor
                                  Found in obj_tables/migrate.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def __init__(self, repo_location=None, repo_url=None, branch='master', search_parent_directories=False):
                                          """ Initialize a :obj:`GitRepo` from an existing Git repo
                                  
                                          If :obj:`repo_location` is a directory then use the Git repo in the directory. Otherwise it must
                                          be an URL and the repo is cloned into a temporary directory.
                                  Severity: Minor
                                  Found in obj_tables/migrate.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 make_data_schema_migration_conf_file_cmd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def make_data_schema_migration_conf_file_cmd(data_repo_dir, schema_file_url, files_to_migrate,
                                                                                   add_to_repo=True):
                                          """ Make a data-schema migration configuration file from CLI input
                                  
                                          Args:
                                  Severity: Minor
                                  Found in obj_tables/migrate.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 all_schema_changes_with_commits has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def all_schema_changes_with_commits(schema_repo):
                                          """ Instantiate all schema changes in a git repo
                                  
                                          Obtain all validated schema change files.
                                  
                                  
                                  Severity: Minor
                                  Found in obj_tables/migrate.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 make_migration_config_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def make_migration_config_file(data_git_repo, schema_repo_name, add_to_repo=True, **kwargs):
                                          """ Create a data-schema migration config file
                                  
                                          Args:
                                              data_git_repo (:obj:`GitRepo`): the data git repo that contains the data files to migrate
                                  Severity: Minor
                                  Found in obj_tables/migrate.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 verify_schemas has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def verify_schemas(self):
                                          """ Verify that each schema can be independently imported
                                  
                                          It can be difficult to import a schema via `importlib.import_module()` in
                                          `import_module_for_migration()`. This method tests that proactively.
                                  Severity: Minor
                                  Found in obj_tables/migrate.py - About 25 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 __str__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def __str__(self):
                                          """ Get string representation
                                  
                                          Returns:
                                              :obj:`str`: string representation of a :obj:`Migrator`; collections attributes are rendered
                                  Severity: Minor
                                  Found in obj_tables/migrate.py - About 25 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 load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def load(schema_changes_file):
                                          """ Read a schema changes file
                                  
                                          Args:
                                              schema_changes_file (:obj:`str`): path to the schema changes file
                                  Severity: Minor
                                  Found in obj_tables/migrate.py - About 25 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 commits_as_graph has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def commits_as_graph(self):
                                          """ Make a DAG for this repo's commit dependencies - edges point from dependent commit to parent commit
                                  
                                          The DAG contains all commits in the repo on which the latest commit depends. Also creates
                                          `git_hash_map`, a map from all git hashes to their commits.
                                  Severity: Minor
                                  Found in obj_tables/migrate.py - About 25 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def validate(self):
                                          """ Validate files to migrate, and load all schema changes files
                                  
                                          Raises:
                                              :obj:`MigratorError`: if any files to migrate do not exist,
                                  Severity: Minor
                                  Found in obj_tables/migrate.py - About 25 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_mapped_attribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def _get_mapped_attribute(self, existing_class, existing_attribute):
                                          """ Get the corresponding migrated class and attribute for the existing class and attribute
                                  
                                          Args:
                                              existing_class (:obj:`obj_tables.core.ModelMeta` or :obj:`str`): an existing class
                                  Severity: Minor
                                  Found in obj_tables/migrate.py - About 25 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

                                  There are no issues that match your filters.

                                  Category
                                  Status