KarrLab/obj_tables

View on GitHub

Showing 425 of 542 total issues

Consider simplifying this complex logical expression.
Open

        if (callable(default) or
                (isinstance(default, list) and len(default) > 0) or
                (not isinstance(default, list) and default is not None)) and \
            (callable(related_default) or
                (isinstance(related_default, list) and len(related_default) > 0) or
Severity: Critical
Found in obj_tables/core.py - About 2 hrs to fix

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

        def __init__(self, related_class, related_name='', default=list(), default_cleaned_value=list(),
    Severity: Major
    Found in obj_tables/core.py - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                  if not row or all(cell in ['', None] for cell in row):
                      rows.remove(row)
                  elif row and isinstance(row[0], str) and \
                          row[0].startswith('%/') and row[0].endswith('/%') and \
                          not any(row[1:]):
      Severity: Critical
      Found in obj_tables/io.py - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                    if (not case_insensitive and ((not verbose_name and attr.name == attr_name) or
                                                  (verbose_name and attr.verbose_name == attr_name))) or \
                        (case_insensitive and ((not verbose_name and attr.name.lower() == attr_name.lower()) or
                                               (verbose_name and attr.verbose_name.lower() == attr_name.lower()))):
                        return (None, attr)
        Severity: Critical
        Found in obj_tables/utils.py - About 2 hrs to fix

          Function create_template has 16 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def create_template(path, schema_name, models, title=None, description=None, keywords=None,
          Severity: Major
          Found in obj_tables/io.py - About 2 hrs to fix

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

                def validate(self, obj, value):
                    """ Determine if :obj:`value` is a valid value
            
                    Args:
                        obj (:obj:`Model`): class being validated
            Severity: Minor
            Found in obj_tables/math/numeric.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 get_or_create_model_obj has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_or_create_model_obj(self, model, _serialized_val=None, _clean=True,
                                            **kwargs):
                    """ Get a instance of a model with serialized value :obj:`_serialized_val`, or
                    create an instance if there is no such instance
            
            
            Severity: Minor
            Found in obj_tables/grammar.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 get_xlsx_validation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
                    """ Get XLSX validation
            
                    Args:
                        sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
            Severity: Minor
            Found in obj_tables/core.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 related_validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def related_validate(self, obj, value):
                    """ Determine if :obj:`value` is a valid value of the related attribute
            
                    Args:
                        obj (:obj:`Model`): object being validated
            Severity: Minor
            Found in obj_tables/core.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 deserialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def deserialize(self, value, objects, decoded=None):
                    """ Deserialize value
            
                    Args:
                        value (:obj:`str`): String representation
            Severity: Minor
            Found in obj_tables/core.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 related_validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def related_validate(self, obj, value):
                    """ Determine if :obj:`value` is a valid value of the related attribute
            
                    Args:
                        obj (:obj:`Model`): object being validated
            Severity: Minor
            Found in obj_tables/core.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 clean has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def clean(self, value):
                    """ Convert attribute value into the appropriate type
            
                    Args:
                        value (:obj:`object`): value of attribute to clean
            Severity: Minor
            Found in obj_tables/core.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 related_validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def related_validate(self, obj, value):
                    """ Determine if :obj:`value` is a valid value of the related attribute
            
                    Args:
                        obj (:obj:`Model`): object being validated
            Severity: Minor
            Found in obj_tables/core.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 __init__ has 15 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, related_class, related_name='',
            Severity: Major
            Found in obj_tables/core.py - About 1 hr to fix

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

                  def __init__(self, related_class, related_name='', default=list(), default_cleaned_value=list(),
              Severity: Major
              Found in obj_tables/core.py - About 1 hr to fix

                Function write_model has 15 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def write_model(self, writer, model, objects, schema_name, date, doc_metadata, doc_metadata_model, model_metadata, sheet_models,
                Severity: Major
                Found in obj_tables/io.py - About 1 hr to fix

                  Function init_schema has 44 lines of code (exceeds 25 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 1 hr to fix

                    Function value has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def value(self, value):
                            if value is None:
                                self._value = None
                                self._serialized_value = None
                                self._serialized_format = None
                    Severity: Minor
                    Found in obj_tables/chem/core.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 get_xlsx_validation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
                            """ Get XLSX validation
                    
                            Args:
                                sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
                    Severity: Minor
                    Found in obj_tables/sci/onto.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 transform has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def transform(filename):
                        # read
                        wb = openpyxl.load_workbook(filename=filename)
                    
                        for ws in wb:
                    Severity: Minor
                    Found in migrations/migration_2020_03_09.py - About 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

                    Severity
                    Category
                    Status
                    Source
                    Language