KarrLab/obj_tables

View on GitHub

Showing 425 of 542 total issues

Function validate has a Cognitive Complexity of 8 (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/core.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 get_xlsx_validation has a Cognitive Complexity of 8 (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 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 clean has a Cognitive Complexity of 8 (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 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 get_xlsx_validation has a Cognitive Complexity of 8 (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 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, min=None, max=None, none=False, default=None, default_cleaned_value=None,
                 none_value=None, verbose_name='', description='', primary=False, unique=False):
        """
        Args:
            min (:obj:`int`, optional): minimum value
Severity: Minor
Found in obj_tables/core.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 set_related_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def set_related_value(self, obj, new_value):
        """ Update the values of the related attributes of the attribute

        Args:
            obj (:obj:`object`): object whose attribute should be set
Severity: Minor
Found in obj_tables/core.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 validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, obj, value):
        """ Determine if :obj:`value` is a valid value of the attribute

        Args:
            obj (:obj:`Model`): object being validated
Severity: Minor
Found in obj_tables/core.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, type=str, separator=',', default=[], none_value=[], verbose_name='',
Severity: Minor
Found in obj_tables/core.py - About 45 mins to fix

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

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

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

          def merge(self, other, normalize=True, validate=True):
              """ Merge another model into a model
      
              Args:
                  other (:obj:`Model`): other model
      Severity: Minor
      Found in obj_tables/core.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 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 attr_name in cls.Meta.attributes:
                                    other_cls = attr.related_class
                                else:
                                    other_cls = attr.primary_class
        
        
        Severity: Major
        Found in obj_tables/core.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for sub_attr in sub_attrs:
                                      if val:
                                          sub_val = getattr(val, sub_attr.name)
                                          if isinstance(sub_attr, RelatedAttribute):
                                              obj_data.append(sub_attr.serialize(sub_val, encoded=encoded))
          Severity: Major
          Found in obj_tables/io.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if not sub_obj:
                                        sub_obj = group_attr.related_class()
                                        setattr(obj, group_attr.name, sub_obj)
                                    setattr(sub_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 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

                                        for i_el, el_diff in enumerate(difference['attributes'][attr_name]):
                                            if isinstance(el_diff, dict):
                                                el_prefix = '\n{}element: {}: "{}" != element: {}: "{}"'.format(
                                                    ' ' * 2 * (indent + 2),
                                                    el_diff['objects'][0].__class__.__name__,
                Severity: Major
                Found in obj_tables/core.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if new_to_render:
                                              new_to_render[0][2] = prefix + new_to_render[0][2]
                                              new_to_render.reverse()
                                              to_render.extend(new_to_render)
                                      else:
                  Severity: Major
                  Found in obj_tables/core.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if isinstance(attr, RelatedAttribute):
                                                if val is None:
                                                    json_val = None
                                                elif isinstance(val, list):
                                                    json_val = []
                    Severity: Major
                    Found in obj_tables/core.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if metacls.CHECK_SAME_RELATED_ATTRIBUTE_NAME and \
                                                      attr.related_name in related_class.Meta.related_attributes and \
                                                      related_class.Meta.related_attributes[attr.related_name] is not attr:
                                                  other_attr = related_class.Meta.related_attributes[
                                                      attr.related_name]
                      Severity: Major
                      Found in obj_tables/core.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if new_to_msg:
                                                    msg += prefix + new_to_msg
                                                    prefix = ''
                        
                        
                        Severity: Major
                        Found in obj_tables/core.py - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language