Total Lines | 19 |
Duplicated Lines | 100 % |
Changes | 5 | ||
Bugs | 0 | Features | 1 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | # coding: utf-8 |
||
6 | View Code Duplication | class Meals(models.Model): |
|
|
|||
7 | |||
8 | """ |
||
9 | Meals |
||
10 | """ |
||
11 | user = models.ForeignKey(User, on_delete=models.CASCADE) |
||
12 | food = models.TextField() |
||
13 | breakfast_lunch_diner = models.CharField(max_length=2) |
||
14 | date_meals = models.DateField(null=True) |
||
15 | hour_meals = models.TimeField(null=True) |
||
16 | created = models.DateTimeField(auto_now_add=True) |
||
17 | modified = models.DateTimeField(auto_now=True) |
||
18 | |||
19 | class Meta: |
||
20 | verbose_name = 'Meal' |
||
21 | verbose_name_plural = 'Meals' |
||
22 | |||
23 | def __str__(self): |
||
24 | return "%s (date: %s)" % (self.food, self.date_meals) |
||
25 |