r4fek/django-cassandra-engine

View on GitHub

Showing 25 of 48 total issues

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

        def get_field_kwargs(self, field_name, model_field):
            """Creates a default instance of a basic non-relational field."""
            kwargs = {}
            validator_kwarg = list(model_field.validators)
    
    
    Severity: Minor
    Found in django_cassandra_engine/rest/serializers.py - About 5 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 _get_unique_checks has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_unique_checks(self, exclude=None):
        # Taken from django.db.models.base
        if exclude is None:
            exclude = []
        unique_checks = []
    Severity: Minor
    Found in django_cassandra_engine/models/django_model_methods.py - About 5 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 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 _perform_unique_checks has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _perform_unique_checks(self, unique_checks):
        # Taken from django.db.models.base
        errors = {}
    
        for model_class, unique_check in unique_checks:
    Severity: Minor
    Found in django_cassandra_engine/models/django_model_methods.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 formfield has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def formfield(self, form_class=None, choices_form_class=None, **kwargs):
          # Taken from django.db.models.fields.__init__
          defaults = {
              "required": not self.blank,
              "label": capfirst(self.verbose_name),
      Severity: Minor
      Found in django_cassandra_engine/models/django_field_methods.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 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 full_clean has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def full_clean(self, exclude=None, validate_unique=True):
          # Taken from django.db.models.base
          errors = {}
          if exclude is None:
              exclude = []
      Severity: Minor
      Found in django_cassandra_engine/models/django_model_methods.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 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 get_cql_models has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_cql_models(app, connection=None, keyspace=None):
          """
          :param app: django models module
          :param connection: connection name
          :param keyspace: keyspace
      Severity: Minor
      Found in django_cassandra_engine/utils.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 get_cassandra_connection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_cassandra_connection(alias=None, name=None):
            """:return: cassandra connection matching alias or name or just first found."""
            for _alias, connection in get_cassandra_connections():
                if alias is not None:
                    if alias == _alias:
        Severity: Minor
        Found in django_cassandra_engine/utils.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 _perform_date_checks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def _perform_date_checks(self, date_checks):
            # Taken from django.db.models.base
            errors = {}
            for model_class, lookup_type, field, unique_for in date_checks:
                lookup_kwargs = {}
        Severity: Minor
        Found in django_cassandra_engine/models/django_model_methods.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 _import_management has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def _import_management():
                """
                Import the 'management' module within each installed app, to register
                dispatcher events.
                """
        Severity: Minor
        Found in django_cassandra_engine/management/commands/sync_cassandra.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 run_validators has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def run_validators(self, value):
            # Taken from django.db.models.fields.__init__
            if value in self.empty_values:
                return
        
        
        Severity: Minor
        Found in django_cassandra_engine/models/django_field_methods.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 clean_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def clean_fields(self, exclude=None):
            # Taken from django.db.models.base
            if exclude is None:
                exclude = []
        
        
        Severity: Minor
        Found in django_cassandra_engine/models/django_model_methods.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 build_standard_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def build_standard_field(self, field_name, model_field):
                """Create regular model fields."""
                field_mapping = ClassLookupDict(self.serializer_field_mapping)
        
                field_class = field_mapping[model_field]
        Severity: Minor
        Found in django_cassandra_engine/rest/serializers.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

        Severity
        Category
        Status
        Source
        Language