KarrLab/obj_tables

View on GitHub

Showing 425 of 542 total issues

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 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 _expr_has_a_constant has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _expr_has_a_constant(self):
              """ Determine whether the expression contains a constant term
      
              The expression must be transformed by removing unary operators, distribing multiplication,
              moving coeffecients left, and multiplying numbers before calling this.
      Severity: Minor
      Found in obj_tables/math/expression.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 serialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def serialize(self, value):
              """ Serialize ontology instance
      
              Args:
                  value (:obj:`pronto.Term`): Python representation
      Severity: Minor
      Found in obj_tables/sci/onto.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 gen_transformer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def gen_transformer(cls, model):
              """ Generate transformer for model
      
              Args:
                  model (:obj:`type`): model
      Severity: Minor
      Found in obj_tables/grammar.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

                              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

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

                def visit_BinOp(self, node):
                    self.generic_visit(node)
                    if (isinstance(node.op, ast.Mult) and
                        (isinstance(node.right, (ast.Num, ast.Name, ast.UnaryOp, ast.BinOp)) and
                         (isinstance(node.left, ast.BinOp) and
        Severity: Minor
        Found in obj_tables/math/expression.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 value_equal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def value_equal(self, val1, val2, tol=0.):
                """ Determine if attribute values are equal
        
                Args:
                    val1 (:obj:`uncertainties.core.Variable`): first value
        Severity: Minor
        Found in obj_tables/sci/uncertainty.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

          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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, default=None, none_value=None, verbose_name='', description='',
            Severity: Minor
            Found in obj_tables/math/numeric.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if cls.__module__ + '.' + cls.__name__ == self.compartment_cls:
                                          self.compartment_cls = cls
                                          break
                                  else:
              Severity: Major
              Found in obj_tables/chem/core.py - About 45 mins to fix

                Function transform has a Cognitive Complexity of 8 (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_04_27.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

                                            if cls is not None:
                                                raise ParsedExpressionError(f"multiple models with id='{id}' in expression '{self.expression}'")
                                            cls, model = related_class, related_obj
                Severity: Major
                Found in obj_tables/math/expression.py - About 45 mins to fix

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

                      def __init__(self, default=None, none_value=None, verbose_name='', description="A chemical formula (e.g. 'H2O', 'CO2', or 'NaCl')",
                  Severity: Minor
                  Found in obj_tables/chem/core.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

                    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

                    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

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

                          def __init__(self, default=None, none_value=None, verbose_name='', description='',
                      Severity: Minor
                      Found in obj_tables/bio/seq.py - About 45 mins to fix

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language