django/django

View on GitHub
django/db/migrations/questioner.py

Summary

Maintainability
B
7 hrs
Test Coverage

File questioner.py has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime
import importlib
import os
import sys

Severity: Minor
Found in django/db/migrations/questioner.py - About 3 hrs to fix

    Function ask_initial has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def ask_initial(self, app_label):
            """Should we create an initial migration for the app?"""
            # If it was specified on the command line, definitely true
            if app_label in self.specified_apps:
                return True
    Severity: Minor
    Found in django/db/migrations/questioner.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in django/db/migrations/questioner.py - About 45 mins to fix

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

          def ask_rename(self, model_name, old_name, new_name, field_instance):
      Severity: Minor
      Found in django/db/migrations/questioner.py - About 35 mins to fix

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

            def _choice_input(self, question, choices):
                self.prompt_output.write(f"{question}")
                for i, choice in enumerate(choices):
                    self.prompt_output.write(" %s) %s" % (i + 1, choice))
                self.prompt_output.write("Select an option: ", ending="")
        Severity: Minor
        Found in django/db/migrations/questioner.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 not any(x.endswith(".py") for x in filenames if x != "__init__.py")
        Severity: Major
        Found in django/db/migrations/questioner.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return False
          Severity: Major
          Found in django/db/migrations/questioner.py - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status