stphivos/django-mock-queries

View on GitHub
django_mock_queries/mocks.py

Summary

Maintainability
C
1 day
Test Coverage

File mocks.py has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import sys
import django
import weakref
from django.apps import apps
Severity: Minor
Found in django_mock_queries/mocks.py - About 4 hrs to fix

    Function mocked_relations has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    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,
    Severity: Minor
    Found in django_mock_queries/mocks.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 compiler has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def compiler(queryset, using=None, connection=None, elide_empty=True, **kwargs):
    Severity: Minor
    Found in django_mock_queries/mocks.py - About 35 mins to fix

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

      def find_all_models(models):
          """ Yield all models and their parents. """
          for model in models:
              yield model
              # noinspection PyProtectedMember
      Severity: Minor
      Found in django_mock_queries/mocks.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

      There are no issues that match your filters.

      Category
      Status