KarrLab/obj_tables

View on GitHub

Showing 425 of 542 total issues

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

""" Toolkit for modeling complex datasets with collections of user-friendly tables

Many classes contain the methods ``serialize()`` and `deserialize()``, which invert each other.
``serialize()`` converts a python object instance into a string representation, whereas
``deserialize()`` parses an object's string representation -- as would be stored in a file or spreadsheet
Severity: Major
Found in obj_tables/core.py - About 2 wks to fix

    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

      File io.py has 2243 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """ Reading/writing schema objects to/from files
      
      * Comma separated values (.csv)
      * XLSX (.xlsx)
      * JavaScript Object Notation (.json)
      Severity: Major
      Found in obj_tables/io.py - About 6 days to fix

        File expression.py has 1493 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """ Utilities for processing mathematical expressions used by obj_tables models
        
        :Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu>
        :Author: Jonathan Karr <karr@mssm.edu>
        :Date: 2018-12-19
        Severity: Major
        Found in obj_tables/math/expression.py - About 3 days to fix

          Function init_schema has a Cognitive Complexity of 154 (exceeds 5 allowed). Consider refactoring.
          Open

          def init_schema(filename, out_filename=None):
              """ Initialize an `ObjTables` schema from a tabular declarative specification in
              :obj:`filename`. :obj:`filename` can be a XLSX, CSV, or TSV file.
          
              Schemas (classes and attributes) should be defined using the following tabular format.
          Severity: Minor
          Found in obj_tables/utils.py - About 3 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 run has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring.
          Open

              def run(self, path, schema_name=None, models=None,
                      allow_multiple_sheets_per_model=False,
                      ignore_missing_models=False, ignore_extra_models=False,
                      ignore_sheet_order=False,
                      include_all_attributes=True, ignore_missing_attributes=False, ignore_extra_attributes=False,
          Severity: Minor
          Found in obj_tables/io.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

          File SBtab.py has 1031 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # Schema automatically generated at 2020-05-29 00:27:56
          
          import obj_tables
          
          
          
          Severity: Major
          Found in examples/sbtab/SBtab.py - About 2 days 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 read_model has a Cognitive Complexity of 109 (exceeds 5 allowed). Consider refactoring.
            Open

                def read_model(self, reader, sheet_name, schema_name, model, include_all_attributes=True,
                               ignore_missing_attributes=False, ignore_extra_attributes=False,
                               ignore_attribute_order=False, ignore_empty_rows=True,
                               validate=True):
                    """ Instantiate a list of objects from data in a table in a file
            Severity: Minor
            Found in obj_tables/io.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

            File utils.py has 881 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """ Utilities
            
            :Author: Jonathan Karr <karr@mssm.edu>
            :Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu>
            :Date: 2016-11-23
            Severity: Major
            Found in obj_tables/utils.py - About 2 days to fix

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

              """ Chemistry attributes
              
              :Author: Jonathan Karr <karr@mssm.edu>
              :Date: 2017-05-10
              :Copyright: 2017, Karr Lab
              Severity: Major
              Found in obj_tables/chem/core.py - About 2 days to fix

                Function write_model has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
                Open

                    def write_model(self, writer, model, objects, schema_name, date, doc_metadata, doc_metadata_model, model_metadata, sheet_models,
                                    include_all_attributes=True, encoded=None, write_empty_models=True, write_empty_cols=True,
                                    extra_entries=0, protected=True):
                        """ Write a list of model objects to a file
                
                
                Severity: Minor
                Found in obj_tables/io.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 from_dict has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
                Open

                    def from_dict(json, models, decode_primary_objects=True, primary_objects=None, decoded=None, ignore_extra_models=False,
                                  validate=False, output_format=None):
                        """ Decode a simple Python representation (dict, list, str, float, bool, None) of an object that
                        is compatible with JSON and YAML, including references to objects through :obj:`__id` keys.
                
                
                Severity: Minor
                Found in obj_tables/core.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 viz_schema has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
                Open

                def viz_schema(module, filename, attributes=True, tail_labels=True, hidden_classes=None, extra_edges=None,
                               model_names=None,
                               rank_sep=None,
                               node_sep=None,
                               node_width=None,
                Severity: Minor
                Found in obj_tables/utils.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

                File web_service.py has 590 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """ Web service
                
                :Author: Jonathan Karr <karr@mssm.edu>
                :Date: 2019-09-15
                :Copyright: 2019, Karr Lab
                Severity: Major
                Found in obj_tables/web_service.py - About 1 day to fix

                  Function validate_attr_tuples has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def validate_attr_tuples(metacls, name, bases, namespace, meta_attribute_name):
                          """ Validate a tuple of tuples of attribute names
                  
                          Args:
                              meta_attribute_name (:obj:`str`): the name of the attribute to validate and normalize
                  Severity: Minor
                  Found in obj_tables/core.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 link_model has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def link_model(self, model, attributes, data, objects, objects_by_primary_attribute, decoded=None):
                          """ Construct object graph
                  
                          Args:
                              model (:obj:`Model`): an :obj:`obj_tables.core.Model`
                  Severity: Minor
                  Found in obj_tables/io.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 tokenize has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def tokenize(self, case_fold_match=False):
                          """ Tokenize a Python expression in :obj:`self.expression`
                  
                          Args:
                              case_fold_match (:obj:`bool`, optional): if set, casefold identifiers before matching;
                  Severity: Minor
                  Found in obj_tables/math/expression.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

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

                  class Model(object, metaclass=ModelMeta):
                      """ Base object model
                  
                      Attributes:
                          _source (:obj:`ModelSource`): file location, worksheet, column, and row where the object was defined
                  Severity: Major
                  Found in obj_tables/core.py - About 1 day to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language