Total Lines | 21 |
Duplicated Lines | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |
||
7 | View Code Duplication | class ExercisesForm(forms.ModelForm): |
|
|
|||
8 | """ |
||
9 | Exercises Form |
||
10 | """ |
||
11 | comment = forms.CharField(widget=forms.Textarea( |
||
12 | {'class': 'form-control', 'rows': '3'})) |
||
13 | duration = forms.IntegerField(widget=forms.TextInput( |
||
14 | {'class': 'form-control', 'type': 'number'})) |
||
15 | date_exercises = forms.DateField(widget=forms.TextInput( |
||
16 | attrs={'class': 'form-control'})) |
||
17 | hour_exercises = forms.TimeField(widget=forms.TextInput( |
||
18 | attrs={'class': 'form-control'})) |
||
19 | |||
20 | class Meta: |
||
21 | model = Exercises |
||
22 | fields = ['sports', 'comment', 'duration', |
||
23 | 'date_exercises', 'hour_exercises'] |
||
24 | |||
25 | def __init__(self, *args, **kwargs): |
||
26 | super(ExercisesForm, self).__init__(*args, **kwargs) |
||
27 | self.fields['sports'].widget.attrs['class'] = 'form-control' |
||
28 |