django/django

View on GitHub
django/contrib/staticfiles/finders.py

Summary

Maintainability
C
1 day
Test Coverage

File finders.py has 278 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import functools
import os

from django.apps import apps
from django.conf import settings
Severity: Minor
Found in django/contrib/staticfiles/finders.py - About 2 hrs to fix

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

        def check(self, **kwargs):
            errors = []
            if not isinstance(settings.STATICFILES_DIRS, (list, tuple)):
                errors.append(
                    Error(
    Severity: Minor
    Found in django/contrib/staticfiles/finders.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 find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def find(self, path, all=False):
            """
            Look for files in the app directories.
            """
            matches = []
    Severity: Minor
    Found in django/contrib/staticfiles/finders.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

    Function find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def find(self, path, all=False):
            """
            Look for files in the extra locations as defined in STATICFILES_DIRS.
            """
            matches = []
    Severity: Minor
    Found in django/contrib/staticfiles/finders.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

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

        def __init__(self, app_names=None, *args, **kwargs):
            # List of locations with static files
            self.locations = []
            # Maps dir paths to an appropriate storage instance
            self.storages = {}
    Severity: Minor
    Found in django/contrib/staticfiles/finders.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

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

        def __init__(self, app_names=None, *args, **kwargs):
            # The list of apps that are handled
            self.apps = []
            # Mapping of app names to storage instances
            self.storages = {}
    Severity: Minor
    Found in django/contrib/staticfiles/finders.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

    Function list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def list(self, ignore_patterns):
            """
            List all files in all locations.
            """
            for prefix, root in self.locations:
    Severity: Minor
    Found in django/contrib/staticfiles/finders.py - About 25 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 find has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def find(self, path, all=False):
            """
            Look for files in the default file storage, if it's local.
            """
            try:
    Severity: Minor
    Found in django/contrib/staticfiles/finders.py - About 25 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 list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def list(self, ignore_patterns):
            """
            List all files in all app storages.
            """
            for storage in self.storages.values():
    Severity: Minor
    Found in django/contrib/staticfiles/finders.py - About 25 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

    There are no issues that match your filters.

    Category
    Status