Function post
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
def post(self):
errors = dict()
success = False
form = SettingsForm(self.request.arguments)
current_user = self.decoded_username()
Similar blocks of code found in 2 locations. Consider refactoring.
def _course_in_database(course_dict, db, q):
"""Check if a course is in the database.
Keyword arguments:
course_dict -- a dictionary specifying the course to check
Similar blocks of code found in 2 locations. Consider refactoring.
def _school_in_database(school_dict, db, q):
"""Check if a school is in the database.
Keyword arguments:
school_dict -- a dictionary specifying the school to check
Similar blocks of code found in 2 locations. Consider refactoring.
@property
def pw_hash(self):
h = None
try:
h = self.password_hash.tobytes()
Similar blocks of code found in 2 locations. Consider refactoring.
@property
def pw_salt(self):
s = None
try:
s = self.password_salt.tobytes()
Similar blocks of code found in 2 locations. Consider refactoring.
course_dict = {"school_id": school_id,
"name": course['name'],
"description": course['fullname'],
"number": course['number'],
"subject": course['school']}
Function add_to_database
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def add_to_database(grouch_output, db):
"""
Add courses from Grouch's output to a db.
Keyword arguments:
Similar blocks of code found in 2 locations. Consider refactoring.
section_dict = {"course_id": course_id,
"semester": course['semester'],
"year": course['year'],
"name": section['section_id'],
"crn": section['crn']}
Function createLookups
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
def createLookups(self):
instanceCounter = 0
featureCounter = 0
for instance in self.dataDict:
if instance not in self.instanceLookup:
Similar blocks of code found in 2 locations. Consider refactoring.
school = StringField(u'school', [wtfv.required(message="Please enter a school"),
wtfv.Length(min=3, max=15, message="School must be 3-15 characters")])
Similar blocks of code found in 2 locations. Consider refactoring.
username = StringField(u'username',
[wtfv.required(message="Please enter a username"),
wtfv.Length(min=3, max=25, message="Username must be 3-25 characters")])
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring.
def __init__(self, data=dict(), numRecommendations=1, db=None, metric="rating", school="gatech"):
Function getRecommendation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def getRecommendation(self, instances):
if(self.updated):
self.sparseifyData()
self.model = self.svd.inverse_transform(self.svd.fit_transform(self.sparsedata))
self.updated = False
Function post
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def post(self):
errors = dict()
form = LoginForm(self.request.arguments)
if form.validate():
try:
Function post
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
def post(self):
errors = dict()
form = RegistrationForm(self.request.arguments)
if form.validate():
h, s = authenticate.create_password(self.get_argument('password'))
Similar blocks of code found in 3 locations. Consider refactoring.
rating = IntegerField(u'rating',
[wtfv.required(message=required_field_msg),
wtfv.NumberRange(min=0, max=5)])
Similar blocks of code found in 3 locations. Consider refactoring.
course = StringField(u'course',
[wtfv.required(message=required_field_msg),
wtfv.length(min=4, max=12)])
Similar blocks of code found in 3 locations. Consider refactoring.
section = StringField(u'section',
[wtfv.required(message=required_field_msg),
wtfv.length(min=1, max=4)])
Function sparseifyData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def sparseifyData(self):
data = self.dataset.getData()
sparsematrix = sparse.dok_matrix((len(data), len(data[0])))
for i in range(len(data)):
for j in range(len(data[i])):
Function optionalLength
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def optionalLength(min, max, message):
"""Ensures a field is either empty, or between min-max characters"""
def _optionalLength(form, field):
if len(field.data) > 0:
if len(field.data) < min or len(field.data) > max: