knipknap/django-find

View on GitHub

Showing 15 of 23 total issues

Searchable has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

class Searchable(object):
    """
    This class is a mixin for Django models that provides methods for
    searching the model using query strings and other tools.
    """
Severity: Minor
Found in django_find/models.py - About 2 hrs to fix

    File models.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    This module contains the Searchable mixin, the main public API of
    django-find.
    """
    from collections import OrderedDict
    Severity: Minor
    Found in django_find/models.py - About 2 hrs to fix

      Function get_object_vector_to has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_object_vector_to(cls, search_cls, subtype, avoid=None):
          """
          Returns a list of all possible paths to the given class.
          Only searches classes that are subtype of the given class.
          """
      Severity: Minor
      Found in django_find/refs.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 optimize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def optimize(self):
              children = [c.optimize() for c in self.children]
              self.children = [c for c in children if c is not None]
              children = []
              for child in self.children:
      Severity: Minor
      Found in django_find/dom.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_join_data has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def _get_join_data(last_cls, to_cls):
          result = []
          last_table_name = last_cls._meta.db_table
      
          # Two options: The current class has a reference to the other table,
      Severity: Minor
      Found in django_find/refs.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 parse_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_field(self, scopes, match):
              field_name = match.group(1).lower()
              field = self.fields.get(field_name)
              if field is None:
                  self.parse_word(scopes, match)
      Severity: Minor
      Found in django_find/parsers/query.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 _create_select has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _create_select(self, fields):
              # Create the "SELECT DISTINCT table1.col1, table2.col2, ..."
              # part of the SQL.
              col_numbers = defaultdict(int)
              fullfields = []
      Severity: Minor
      Found in django_find/serializers/sql.py - About 55 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_subclasses has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_subclasses(cls):
          """
          Recursively finds all subclasses of the current class.
          Like Python's __class__.__subclasses__(), but recursive.
          Returns a list containing all subclasses.
      Severity: Minor
      Found in django_find/refs.py - About 55 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 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, model, raw_query, args=None, limit=None, offset=None):
      Severity: Minor
      Found in django_find/rawquery.py - About 35 mins to fix

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

        def sql_from_dom(cls, dom, mode='SELECT', fullnames=None, extra_model=None):
        Severity: Minor
        Found in django_find/model_helpers.py - About 35 mins to fix

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

          def yield_matching_vectors(vectors, search_cls_list):
              """
              Yields all possible vectors that connect all of the given classes.
              The result is sorted by the position of the primary class, and
              the vector length.
          Severity: Minor
          Found in django_find/refs.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

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

              def get_class_from_fullname(cls, fullname):
                  """
                  Given a name in the format "Model.hostname", this
                  function returns a tuple, where the first element is the Model
                  class, and the second is the field name "hostname".
          Severity: Minor
          Found in django_find/models.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

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

              def get_fullnames(cls, unique=False):
                  """
                  Like get_aliases(), but returns the aliases prefixed by the class
                  name.
                  """
          Severity: Minor
          Found in django_find/models.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

          Function logical_root_group has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def logical_root_group(self, root_group, terms):
                  fields = self._create_db_column_list(root_group)
          
                  # Create the SELECT part of the query.
                  if self.mode == 'SELECT':
          Severity: Minor
          Found in django_find/serializers/sql.py - About 25 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 yield_all_vectors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def yield_all_vectors(search_cls_list, subtype):
              """ 
              Yields all possible vectors between all given classes.
              """
              for target_cls in search_cls_list[:]:
          Severity: Minor
          Found in django_find/refs.py - About 25 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