stphivos/django-mock-queries

View on GitHub
django_mock_queries/query.py

Summary

Maintainability
D
2 days
Test Coverage

MockSet has 40 functions (exceeds 20 allowed). Consider refactoring.
Open

class MockSet(MagicMock, metaclass=MockSetMeta):
    EVENT_ADDED = 'added'
    EVENT_UPDATED = 'updated'
    EVENT_SAVED = 'saved'
    EVENT_DELETED = 'deleted'
Severity: Minor
Found in django_mock_queries/query.py - About 5 hrs to fix

    File query.py has 371 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import datetime
    import random
    from collections import OrderedDict, namedtuple
    from unittest.mock import Mock, MagicMock, PropertyMock
    
    
    Severity: Minor
    Found in django_mock_queries/query.py - About 4 hrs to fix

      Function aggregate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def aggregate(self, *args, **kwargs):
              result = {}
      
              for expr in set(args):
                  kwargs['{0}__{1}'.format(expr.source_expressions[0].name, expr.function).lower()] = expr
      Severity: Minor
      Found in django_mock_queries/query.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 _item_values has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _item_values(self, item, fields):
              field_buckets = {}
              result_count = 1
      
              if len(fields) == 0:
      Severity: Minor
      Found in django_mock_queries/query.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 load_fields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_fields(self, *field_names):
              fields = {name: MockField(name) for name in field_names}
      
              for key in ('_forward_fields_map', 'parents', 'fields_map'):
                  self.__dict__[key] = {}
      Severity: Minor
      Found in django_mock_queries/query.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 _get_order_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_order_fields(self, fields, field_name):
              if fields and field_name is not None:
                  raise ValueError('Cannot use both positional arguments and the field_name keyword argument.')
      
              if field_name is not None:
      Severity: Minor
      Found in django_mock_queries/query.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 update_or_create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_or_create(self, defaults=None, **attrs):
              if defaults is not None:
                  validate_mock_set(self)
              defaults = defaults or {}
              lookup = attrs.copy()
      Severity: Minor
      Found in django_mock_queries/query.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 annotate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def annotate(self, **kwargs):
              results = list(self.items)
              for key, value in kwargs.items():
                  for row in results:
                      if not hasattr(row, '_annotated_fields'):
      Severity: Minor
      Found in django_mock_queries/query.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 _values_row has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _values_row(self, values_dict, fields, **kwargs):
              flat = kwargs.pop('flat', False)
              named = kwargs.pop('named', False)
      
              if kwargs:
      Severity: Minor
      Found in django_mock_queries/query.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