django/django

View on GitHub
django/core/management/commands/makemigrations.py

Summary

Maintainability
D
3 days
Test Coverage

Function handle has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(self, *app_labels, **options):
        self.written_files = []
        self.verbosity = options["verbosity"]
        self.interactive = options["interactive"]
        self.dry_run = options["dry_run"]
Severity: Minor
Found in django/core/management/commands/makemigrations.py - About 6 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

File makemigrations.py has 440 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import sys
import warnings
from itertools import takewhile

Severity: Minor
Found in django/core/management/commands/makemigrations.py - About 6 hrs to fix

    Function write_migration_files has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_migration_files(self, changes, update_previous_migration_paths=None):
            """
            Take a changes dict and write them out as migration files.
            """
            directory_created = {}
    Severity: Minor
    Found in django/core/management/commands/makemigrations.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 write_to_last_migration_files has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_to_last_migration_files(self, changes):
            loader = MigrationLoader(connections[DEFAULT_DB_ALIAS])
            new_changes = {}
            update_previous_migration_paths = {}
            for app_label, app_migrations in changes.items():
    Severity: Minor
    Found in django/core/management/commands/makemigrations.py - About 3 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

    Avoid deeply nested control flow statements.
    Open

                            if not os.path.isfile(init_path):
                                open(init_path, "w").close()
                            # We just do this once per app
                            directory_created[app_label] = True
    Severity: Major
    Found in django/core/management/commands/makemigrations.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if writer.needs_manual_porting:
                                  migration_path = self.get_relative_path(writer.path)
                                  self.log(
                                      self.style.WARNING(
                                          f"Updated migration {migration_path} requires "
      Severity: Major
      Found in django/core/management/commands/makemigrations.py - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status