| Total Complexity | 3 |
| Total Lines | 13 |
| Duplicated Lines | 100 % |
| Changes | 3 | ||
| 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 | from django.core.management.base import BaseCommand |
||
| 6 | View Code Duplication | class Command(BaseCommand): |
|
|
|
|||
| 7 | help = 'Makes the given user a course owner.' |
||
| 8 | |||
| 9 | def add_arguments(self, parser): |
||
| 10 | parser.add_argument('email', nargs=1, type=str) |
||
| 11 | |||
| 12 | def handle(self, *args, **options): |
||
| 13 | try: |
||
| 14 | u=User.objects.get(email=options['email'][0]) |
||
| 15 | print("Found %s %s (%s), activating course owner rights."%(u.first_name, u.last_name, u.email)) |
||
| 16 | make_owner(u) |
||
| 17 | except User.DoesNotExist: |
||
| 18 | print("This user does not exist.") |
||
| 19 |