django/django

View on GitHub
django/utils/autoreload.py

Summary

Maintainability
D
2 days
Test Coverage

File autoreload.py has 522 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import itertools
import logging
import os
import signal
import subprocess
Severity: Major
Found in django/utils/autoreload.py - About 1 day to fix

    Function watched_roots has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def watched_roots(self, watched_files):
            extra_directories = self.directory_globs.keys()
            watched_file_dirs = [f.parent for f in watched_files]
            sys_paths = list(sys_path_directories())
            return frozenset((*extra_directories, *watched_file_dirs, *sys_paths))
    Severity: Minor
    Found in django/utils/autoreload.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

    Function iter_modules_and_files has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def iter_modules_and_files(modules, extra_files):
        """Iterate through all modules needed to be watched."""
        sys_file_paths = []
        for module in modules:
            # During debugging (with PyDev) the 'typing.io' and 'typing.re' objects
    Severity: Minor
    Found in django/utils/autoreload.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 get_child_arguments has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_child_arguments():
        """
        Return the executable. This contains a workaround for Windows if the
        executable is reported to not have the .exe extension which can cause bugs
        on reloading.
    Severity: Minor
    Found in django/utils/autoreload.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 check_errors has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_errors(fn):
        @wraps(fn)
        def wrapper(*args, **kwargs):
            global _exception
            try:
    Severity: Minor
    Found in django/utils/autoreload.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 ensure_echo_on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def ensure_echo_on():
        """
        Ensure that echo mode is enabled. Some tools such as PDB disable
        it which causes usability issues after reload.
        """
    Severity: Minor
    Found in django/utils/autoreload.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 tick has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def tick(self):
            mtimes = {}
            while True:
                for filepath, mtime in self.snapshot_files():
                    old_time = mtimes.get(filepath)
    Severity: Minor
    Found in django/utils/autoreload.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 common_roots has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def common_roots(paths):
        """
        Return a tuple of common roots that are shared between the given paths.
        File system watchers operate on directories and aren't cheap to create.
        Try to find the minimum set of directories to watch that encompass all of
    Severity: Minor
    Found in django/utils/autoreload.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 sys_path_directories has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def sys_path_directories():
        """
        Yield absolute directories from sys.path, ignoring entries that don't
        exist.
        """
    Severity: Minor
    Found in django/utils/autoreload.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 watched_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def watched_files(self, include_globs=True):
            """
            Yield all files that need to be watched, including module files and
            files within globs.
            """
    Severity: Minor
    Found in django/utils/autoreload.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