django/django

View on GitHub
django/core/management/base.py

Summary

Maintainability
D
1 day
Test Coverage

File base.py has 465 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Base classes for writing management commands (named commands which can
be executed through ``django-admin`` or ``manage.py``).
"""
import os
Severity: Minor
Found in django/core/management/base.py - About 7 hrs to fix

    Function check has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def check(self, app_configs=None, tags=None, display_num_errors=False,
                  include_deployment_checks=False, fail_level=checks.ERROR):
            """
            Use the system check framework to validate entire Django project.
            Raise CommandError for any serious message (error or critical errors).
    Severity: Minor
    Found in django/core/management/base.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

    Function execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def execute(self, *args, **options):
            """
            Try to execute this command, performing system checks if needed (as
            controlled by the ``requires_system_checks`` attribute, except if
            force-skipped).
    Severity: Minor
    Found in django/core/management/base.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 run_from_argv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_from_argv(self, argv):
            """
            Set up any environment changes requested (e.g., Python path
            and Django settings), then run this command. If the
            command raises a ``CommandError``, intercept it and print it sensibly
    Severity: Minor
    Found in django/core/management/base.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 all_issues:
                debugs = [e for e in all_issues if e.level < checks.INFO and not e.is_silenced()]
                infos = [e for e in all_issues if checks.INFO <= e.level < checks.WARNING and not e.is_silenced()]
                warnings = [e for e in all_issues if checks.WARNING <= e.level < checks.ERROR and not e.is_silenced()]
                errors = [e for e in all_issues if checks.ERROR <= e.level < checks.CRITICAL and not e.is_silenced()]
    Severity: Major
    Found in django/core/management/base.py - About 40 mins to fix

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

          def check(self, app_configs=None, tags=None, display_num_errors=False,
      Severity: Minor
      Found in django/core/management/base.py - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status