r4fek/django-cassandra-engine

View on GitHub
django_cassandra_engine/models/__init__.py

Summary

Maintainability
F
4 days
Test Coverage

File __init__.py has 690 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from functools import partial
from itertools import chain
from operator import attrgetter
import collections.abc
import copy
Severity: Major
Found in django_cassandra_engine/models/__init__.py - About 1 day to fix

    Function __new__ has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
    Open

        def __new__(cls, name, bases, attrs):
            parents = [b for b in bases if isinstance(b, DjangoCassandraModelMetaClass)]
    
            if not parents:
                return super(ModelBase, cls).__new__(cls, name, bases, attrs)
    Severity: Minor
    Found in django_cassandra_engine/models/__init__.py - About 1 day 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 python_order_by has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def python_order_by(self, qset, colnames):
            if not isinstance(qset, list):
                raise TypeError("qset must be a list")
            colnames = convert_pk_field_names_to_real(
                model=self.model, field_names=colnames
    Severity: Minor
    Found in django_cassandra_engine/models/__init__.py - About 2 hrs 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 __new__ has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __new__(cls, name, bases, attrs):
            parents = [b for b in bases if isinstance(b, DjangoCassandraModelMetaClass)]
    
            if not parents:
                return super(ModelBase, cls).__new__(cls, name, bases, attrs)
    Severity: Major
    Found in django_cassandra_engine/models/__init__.py - About 2 hrs to fix

      Function order_by has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def order_by(self, *colnames):
              if len(colnames) == 0:
                  clone = copy.deepcopy(self)
                  clone._order = []
                  return clone
      Severity: Minor
      Found in django_cassandra_engine/models/__init__.py - About 2 hrs 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 convert_pk_field_names_to_real has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def convert_pk_field_names_to_real(model, field_names):
          """
          Convert field names including 'pk' to the real field names:
          >>> convert_pk_field_names_to_real(['pk', 'another_field'])
          ['real_pk_field', 'another_field']
      Severity: Minor
      Found in django_cassandra_engine/models/__init__.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 _add_django_meta_and_register_model has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def _add_django_meta_and_register_model(cls, klass, attrs, name):
              # Create the class.
              module = attrs.get("__module__")
              if not module:
                  return klass
      Severity: Minor
      Found in django_cassandra_engine/models/__init__.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 _set_column_django_attributes has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def _set_column_django_attributes(self, cql_column, name):
              allow_null = (
                  (
                      not cql_column.required
                      and not cql_column.is_primary_key
      Severity: Minor
      Found in django_cassandra_engine/models/__init__.py - About 1 hr to fix

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

            def exclude(self, *args, **kwargs):
                new_queryset = []
                for model in self.get_queryset():
                    should_exclude_model = False
                    for field_name, field_value in kwargs.items():
        Severity: Minor
        Found in django_cassandra_engine/models/__init__.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 _give_columns_django_field_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _give_columns_django_field_attributes(self):
                """
                Add Django Field attributes to each cqlengine.Column instance.
                So that the Django Options class may interact with it as if it were
                a Django Field.
        Severity: Minor
        Found in django_cassandra_engine/models/__init__.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

        There are no issues that match your filters.

        Category
        Status