mangroveorg/datawinners

View on GitHub
datawinners/custom_reports/crs/models.py

Summary

Maintainability
F
5 days
Test Coverage

File models.py has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from django.db import models
from mangrove.utils.types import is_empty

def crs_model_creator(data_record_id, submission_data, model, question_mapping=None, defaults=None):
    exists = model.objects.filter(data_record_id=data_record_id)
Severity: Minor
Found in datawinners/custom_reports/crs/models.py - About 3 hrs to fix

    Function crs_model_creator has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def crs_model_creator(data_record_id, submission_data, model, question_mapping=None, defaults=None):
    Severity: Minor
    Found in datawinners/custom_reports/crs/models.py - About 35 mins to fix

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

      class SiteActivities(models.Model):
          data_record_id = models.TextField()
          q1 = models.TextField(db_column='fiscal_year_with_initials')
          q2 = models.TextField(db_column='site_location')
          q3 = models.TextField(db_column='site_gps_coordinates')
      Severity: Major
      Found in datawinners/custom_reports/crs/models.py and 1 other location - About 6 hrs to fix
      datawinners/custom_reports/crs/models.py on lines 137..145

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 106.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      class PhysicalInventorySheet(models.Model):
          data_record_id = models.TextField()
          q1 = models.TextField(db_column='store_house_code')
          q2 = models.DateField(db_column='physical_inventory_closing_date')
          q3 = models.DateField(db_column='actual_physical_inventory_date')
      Severity: Major
      Found in datawinners/custom_reports/crs/models.py and 1 other location - About 6 hrs to fix
      datawinners/custom_reports/crs/models.py on lines 148..156

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 106.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      class DistributionAtCPS(models.Model):
          data_record_id = models.TextField()
          q1 = models.TextField(db_column='centre_code')
          q2 = models.DateField(db_column='received_date')
          q3 = models.TextField(db_column='pl_code')
      Severity: Major
      Found in datawinners/custom_reports/crs/models.py and 1 other location - About 5 hrs to fix
      datawinners/custom_reports/crs/models.py on lines 303..310

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 93.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      class NumberOfRecipientServed(models.Model):
          data_record_id = models.TextField()
          q1 = models.TextField(db_column='received_type')
          q2 = models.DateField(db_column='received_date')
          q3 = models.IntegerField(db_column='no_of_type1_recipient')
      Severity: Major
      Found in datawinners/custom_reports/crs/models.py and 1 other location - About 5 hrs to fix
      datawinners/custom_reports/crs/models.py on lines 312..319

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 93.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      class PackingList(models.Model):
          data_record_id = models.TextField()
          q1 = models.TextField(db_column='pl_code')
          q2 = models.FloatField(db_column='rice_cost')
          q3 = models.FloatField(db_column='oil_cost')
      Severity: Major
      Found in datawinners/custom_reports/crs/models.py and 2 other locations - About 4 hrs to fix
      datawinners/custom_reports/crs/models.py on lines 159..165
      datawinners/custom_reports/crs/models.py on lines 199..205

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      class BreakBulkSent(models.Model):
          data_record_id = models.TextField()
          q1 = models.DateField(db_column='sent_date')
          q2 = models.FloatField(db_column='weight')
          q3 = models.TextField(db_column='waybill_code')
      Severity: Major
      Found in datawinners/custom_reports/crs/models.py and 2 other locations - About 4 hrs to fix
      datawinners/custom_reports/crs/models.py on lines 159..165
      datawinners/custom_reports/crs/models.py on lines 328..334

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      class Warehouse(models.Model):
          data_record_id = models.TextField()
          q1 = models.TextField(db_column='name')
          q2 = models.TextField(db_column='address')
          q3 = models.TextField(db_column='gps_coordinates')
      Severity: Major
      Found in datawinners/custom_reports/crs/models.py and 2 other locations - About 4 hrs to fix
      datawinners/custom_reports/crs/models.py on lines 199..205
      datawinners/custom_reports/crs/models.py on lines 328..334

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 80.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status