Command   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 100 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
dl 13
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 7 7 2

How to fix   Duplicated Code   

Duplicated Code

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
2
from django.contrib.auth.models import User, Group
3
4
from opensubmit.security import make_owner
5
6 View Code Duplication
class Command(BaseCommand):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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