django_mock_queries/mocks.py
File mocks.py
has 360 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import os
import sys
import django
import weakref
from django.apps import apps
Function mocked_relations
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
def mocked_relations(*models):
""" Mock all related field managers to make pure unit tests possible.
The resulting patcher can be used just like one from the mock module:
As a test method decorator, a test class decorator, a context manager,
- Read upRead up
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 compiler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def compiler(queryset, using=None, connection=None, elide_empty=True, **kwargs):
Function find_all_models
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
def find_all_models(models):
""" Yield all models and their parents. """
for model in models:
yield model
# noinspection PyProtectedMember
- Read upRead up
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"