django/django

View on GitHub
django/db/backends/mysql/operations.py

Summary

Maintainability
C
1 day
Test Coverage

File operations.py has 366 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import uuid

from django.conf import settings
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.utils import split_tzname_delta
Severity: Minor
Found in django/db/backends/mysql/operations.py - About 4 hrs to fix

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

        def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
    Severity: Minor
    Found in django/db/backends/mysql/operations.py - About 45 mins to fix

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

          def on_conflict_suffix_sql(self, fields, on_conflict, update_fields, unique_fields):
      Severity: Minor
      Found in django/db/backends/mysql/operations.py - About 35 mins to fix

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

            def datetime_trunc_sql(self, lookup_type, sql, params, tzname):
        Severity: Minor
        Found in django/db/backends/mysql/operations.py - About 35 mins to fix

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

              def datetime_extract_sql(self, lookup_type, sql, params, tzname):
          Severity: Minor
          Found in django/db/backends/mysql/operations.py - About 35 mins to fix

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

                def time_trunc_sql(self, lookup_type, sql, params, tzname=None):
            Severity: Minor
            Found in django/db/backends/mysql/operations.py - About 35 mins to fix

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

                  def date_extract_sql(self, lookup_type, sql, params):
                      # https://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
                      if lookup_type == "week_day":
                          # DAYOFWEEK() returns an integer, 1-7, Sunday=1.
                          return f"DAYOFWEEK({sql})", params
              Severity: Minor
              Found in django/db/backends/mysql/operations.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

              Avoid too many return statements within this function.
              Open

                          return f"EXTRACT({lookup_type} FROM {sql})", params
              Severity: Major
              Found in django/db/backends/mysql/operations.py - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status