r4fek/django-cassandra-engine

View on GitHub

Showing 25 of 48 total issues

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

    def register(self):
        try:
            connection.get_connection(name=self.alias)
        except CQLEngineException:
            if self.default:
Severity: Minor
Found in django_cassandra_engine/connection.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 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

Consider simplifying this complex logical expression.
Open

            if (
                obj.__connection__ == connection
                or (obj.__connection__ is None and is_default_connection)
                or obj.__connection__ is None
                and obj.__keyspace__ is not None
Severity: Major
Found in django_cassandra_engine/utils.py - About 40 mins to fix

    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

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

        def sync(self, alias):
            engine = get_engine_from_db_alias(alias)
    
            if engine != "django_cassandra_engine":
                raise CommandError("Database {} is not cassandra!".format(alias))
    Severity: Minor
    Found in django_cassandra_engine/management/commands/sync_cassandra.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