edukorg/drf-toolkit

View on GitHub

Showing 45 of 54 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="ExclusiveArticle",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="created at")),
test_app/migrations/0005_article_article_test_app_ar_updated_d2ab7e_idx_and_more.py on lines 16..34

Similar blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="News",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="created at")),
test_app/migrations/0006_news_exclusivenews_exclusivearticle_and_more.py on lines 40..65

Similar blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="ExclusiveNews",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="created at")),
test_app/migrations/0006_news_exclusivenews_exclusivearticle_and_more.py on lines 16..37

Similar blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="Article",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="created at")),
test_app/migrations/0006_news_exclusivenews_exclusivearticle_and_more.py on lines 68..89

Function assertResponseMatch has a Cognitive Complexity of 51 (exceeds 7 allowed). Consider refactoring.
Open

def assertResponseMatch(self, expected, received):
def _assert_dict(expected_item, received_item, idx=None):
msg = f"At item #{idx}:: " if idx else ""
 
expected_keys = set(expected_item)
Severity: Minor
Found in drf_kit/tests.py - About 7 hrs to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="BeastOwner",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="created at")),
test_app/migrations/0009_beastcategory_beast_category.py on lines 16..23

Identical blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="BeastCategory",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created_at", models.DateTimeField(auto_now_add=True, verbose_name="created at")),
Severity: Major
Found in test_app/migrations/0009_beastcategory_beast_category.py and 1 other location - About 5 hrs to fix
test_app/migrations/0008_beastowner_beastownership_beastowner_beasts_and_more.py on lines 16..23

Similar blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="HappyTale",
fields=[
(
"tale_ptr",
Severity: Major
Found in test_app/migrations/0002_auto_20220118_1400.py and 1 other location - About 4 hrs to fix
test_app/migrations/0002_auto_20220118_1400.py on lines 51..72

Similar blocks of code found in 2 locations. Consider refactoring.
Open

migrations.CreateModel(
name="DarkTale",
fields=[
(
"tale_ptr",
Severity: Major
Found in test_app/migrations/0002_auto_20220118_1400.py and 1 other location - About 4 hrs to fix
test_app/migrations/0002_auto_20220118_1400.py on lines 74..95

File tests.py has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import inspect
import logging
import os
import re
from collections import Counter
Severity: Minor
Found in drf_kit/tests.py - About 4 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    class SoftDeleteOrderedModel(SoftDeleteModelMixin, OrderedModelMixin, BaseModel):
    objects = SoftDeleteOrderedManager()
     
    class Meta(SoftDeleteModelMixin.Meta, OrderedModelMixin.Meta, BaseModel.Meta):
    abstract = True
    Severity: Major
    Found in drf_kit/models/__init__.py and 1 other location - About 2 hrs to fix
    drf_kit/models/__init__.py on lines 33..38

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    class SoftDeleteAvailabilityModel(SoftDeleteModelMixin, AvailabilityModelMixin, BaseModel):
    objects = SoftDeleteAvailabilityManager()
     
    class Meta(SoftDeleteModelMixin.Meta, AvailabilityModelMixin.Meta, BaseModel.Meta):
    abstract = True
    Severity: Major
    Found in drf_kit/models/__init__.py and 1 other location - About 2 hrs to fix
    drf_kit/models/__init__.py on lines 25..30

    BaseApiTest has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseApiTest(APITransactionTestCase):
    maxDiff = None
     
    def setUp(self):
    super().setUp()
    Severity: Minor
    Found in drf_kit/tests.py - About 2 hrs to fix

      Function save has a Cognitive Complexity of 19 (exceeds 7 allowed). Consider refactoring.
      Open

      def save(self, *args, **kwargs):
      being_created = self.pk is None
       
      super().save(*args, **kwargs)
       
       
      Severity: Minor
      Found in drf_kit/models/file_models.py - About 2 hrs to fix

      Function process_cache_response has a Cognitive Complexity of 15 (exceeds 7 allowed). Consider refactoring.
      Open

      def process_cache_response(
      self,
      view_instance,
      view_method,
      request,
      Severity: Minor
      Found in drf_kit/cache.py - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      class InheritanceOrderedModel(OrderedModelMixin, InheritanceModelMixin, BaseModel):
      class Meta(OrderedModelMixin.Meta, InheritanceModelMixin.Meta, BaseModel.Meta):
      abstract = True
      indexes = OrderedModelMixin.Meta.indexes + BaseModel.Meta.indexes
      Severity: Major
      Found in drf_kit/models/__init__.py and 1 other location - About 1 hr to fix
      drf_kit/models/__init__.py on lines 19..22

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      class SoftDeleteInheritanceModel(SoftDeleteModelMixin, InheritanceModelMixin, BaseModel):
      class Meta(SoftDeleteModelMixin.Meta, InheritanceModelMixin.Meta, BaseModel.Meta):
      abstract = True
      indexes = SoftDeleteModelMixin.Meta.indexes + BaseModel.Meta.indexes
      Severity: Major
      Found in drf_kit/models/__init__.py and 1 other location - About 1 hr to fix
      drf_kit/models/__init__.py on lines 41..44

      Function _get_m2m_relations_for has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
      Open

      def _get_m2m_relations_for(self, fields: Iterable[str]) -> Generator["SoftDeleteModel"]: # noqa: F821
      from drf_kit.models import SoftDeleteModel
       
      related_fields = {field.split("__")[0] for field in fields}
       
       
      Severity: Minor
      Found in drf_kit/managers/soft_delete_managers.py - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      migrations.AddConstraint(
      model_name="roomofrequirement",
      constraint=models.CheckConstraint(
      check=models.Q(("starts_at__lte", models.F("ends_at"))),
      test_app/migrations/0004_newspaper_roomofrequirement_and_more.py on lines 83..86

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      migrations.AddConstraint(
      model_name="newspaper",
      constraint=models.CheckConstraint(
      check=models.Q(("starts_at__lte", models.F("ends_at"))),
      test_app/migrations/0004_newspaper_roomofrequirement_and_more.py on lines 102..105
      Severity
      Category
      Status
      Source
      Language