django/django

View on GitHub
django/contrib/staticfiles/management/commands/collectstatic.py

Summary

Maintainability
D
1 day
Test Coverage

Function collect has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def collect(self):
        """
        Perform the bulk of the work of collectstatic.

        Split off from handle() to facilitate testing.
Severity: Minor
Found in django/contrib/staticfiles/management/commands/collectstatic.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

File collectstatic.py has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os

from django.apps import apps
from django.contrib.staticfiles.finders import get_finders
from django.contrib.staticfiles.storage import staticfiles_storage
Severity: Minor
Found in django/contrib/staticfiles/management/commands/collectstatic.py - About 3 hrs to fix

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

        def handle(self, **options):
            self.set_options(**options)
            message = ['\n']
            if self.dry_run:
                message.append(
    Severity: Minor
    Found in django/contrib/staticfiles/management/commands/collectstatic.py - About 2 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 delete_file has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete_file(self, path, prefixed_path, source_storage):
            """
            Check if the target file should be deleted if it already exists.
            """
            if self.storage.exists(prefixed_path):
    Severity: Minor
    Found in django/contrib/staticfiles/management/commands/collectstatic.py - About 2 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 clear_dir has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def clear_dir(self, path):
            """
            Delete the given relative path using the destination storage backend.
            """
            if not self.storage.exists(path):
    Severity: Minor
    Found in django/contrib/staticfiles/management/commands/collectstatic.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 link_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def link_file(self, path, prefixed_path, source_storage):
            """
            Attempt to link ``path``
            """
            # Skip this file if it was already copied earlier
    Severity: Minor
    Found in django/contrib/staticfiles/management/commands/collectstatic.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

    There are no issues that match your filters.

    Category
    Status