KarrLab/obj_tables

View on GitHub

Showing 425 of 542 total issues

Avoid deeply nested control flow statements.
Open

                        for i_val2 in range(i_val, len(val)):
                            difference['attributes'][attr_name].append(
                                'No matching element {}'.format(serial_vals[i_val2][0]))
                elif val is None:
Severity: Major
Found in obj_tables/core.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if v not in objs_to_keep:
                                val.remove(v)
                    else:
    Severity: Major
    Found in obj_tables/core.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if validation_error:
                                      validation_error.set_location_and_value(utils.source_report(obj, sub_attr.name),
                                                                              attr_value)
                                      obj_errors.append(validation_error)
                              setattr(obj, sub_attr.name, value)
      Severity: Major
      Found in obj_tables/io.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if val is None:
                                    pass
                                elif isinstance(val, Model):
                                    pairs_to_check.append((val, other_val, ))
                                elif len(val) != len(other_val):
        Severity: Major
        Found in obj_tables/core.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for oo in getattr(o, attr_name):
                                      objs[attr.related_class][oo.serialize()] = oo
          
          
          Severity: Major
          Found in obj_tables/core.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if isinstance(attr, (
                                        OneToOneAttribute,
                                        OneToManyAttribute,
                                        ManyToOneAttribute,
                                        ManyToManyAttribute)) and \
            Severity: Major
            Found in obj_tables/core.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if attr.related_class not in objects_by_primary_attribute:
                                          objects_by_primary_attribute[attr.related_class] = {}
                                      serialized_val = val.serialize()
              Severity: Major
              Found in obj_tables/io.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if isinstance(val, list) and len(val) > 1:
                                            if attr_name in obj.Meta.attributes:
                                                cls = attr.related_class
                                            else:
                                                cls = attr.primary_class
                Severity: Major
                Found in obj_tables/core.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if v not in printed_objs:
                                              iter_attr.append(v._tree_str(
                                                  printed_objs, depth + 1, max_depth))
                                      attrs.extend(iter_attr)
                  Severity: Major
                  Found in obj_tables/core.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if deserialize_error:
                                                    deserialize_error.set_location_and_value(utils.source_report(obj, sub_attr.name),
                                                                                             attr_value)
                                                    obj_errors.append(deserialize_error)
                                                if validation_error:
                    Severity: Major
                    Found in obj_tables/io.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def __init__(self, path_name, sheet_name, attribute_seq, row, table_id=None):
                        Severity: Minor
                        Found in obj_tables/core.py - About 35 mins to fix

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

                              def __init__(self, attribute, messages, related=False, location=None, value=None):
                          Severity: Minor
                          Found in obj_tables/core.py - About 35 mins to fix

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

                                def get_children(self, kind=None, __type=None, recursive=True, **kwargs):
                            Severity: Minor
                            Found in obj_tables/core.py - About 35 mins to fix

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

                                  def __init__(self, default=False, default_cleaned_value=None, none_value=None, verbose_name='', description='Enter a Boolean value'):
                              Severity: Minor
                              Found in obj_tables/core.py - About 35 mins to fix

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

                                        def add_to_decoding_queue(json, models_by_name=models_by_name, decoded=decoded, to_decode=to_decode,
                                Severity: Minor
                                Found in obj_tables/core.py - About 35 mins to fix

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

                                      def get_attrs_by_val(self, type=None, reverse=True,
                                  Severity: Minor
                                  Found in obj_tables/core.py - About 35 mins to fix

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

                                    def get_attribute_by_name(cls, group_name, attr_name, verbose_name=False, case_insensitive=False):
                                    Severity: Minor
                                    Found in obj_tables/utils.py - About 35 mins to fix

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

                                      def to_pandas(objs, models=None, get_related=True,
                                      Severity: Minor
                                      Found in obj_tables/utils.py - About 35 mins to fix

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

                                            def _default(self):
                                                args = self.app.pargs
                                                schema_name, schema, models = get_schema_models(args.schema_file)
                                                for model in models:
                                                    if model.__name__ == args.model:
                                        Severity: Minor
                                        Found in obj_tables/__main__.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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language