Showing 24 of 24 total issues
File api.py
has 376 lines of code (exceeds 250 allowed). Consider refactoring. Open
from itertools import chain
from jinja2 import Environment, FileSystemLoader
from flask import Blueprint, jsonify, g, request, current_app
from api.models import Lottery, Classroom, User, Application, db, apps2members
Function login_required
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def login_required(*required_authority):
"""
a decorder to require login
Args:
*required_authority (str): required authorities
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function draw_one_group_members
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def draw_one_group_members(applications, winners_num, set_just=True,
**kwargs):
"""internal function
decide win (waiting) or lose for each group
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function apply_lottery
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def apply_lottery(idx):
"""
apply to the lottery.
specify the lottery id in the URL.
1. check request errors
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function home
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def home():
"""
top page. Require/Check Login
"""
if 'Content-Type' not in request.headers or \
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function results
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def results():
"""return HTML file that contains the results of previous lotteries
This endpoint will be used for printing PDF
which will be put on the wall.
whoever access here can get the file. This is not a problem because
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function draw_one_normal_users
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def draw_one_normal_users(applications, winners_num, **kwargs):
"""internal function
decide win or lose for each user not belonging to a group
add applications to the session
"""
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function set_status
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_status(self, new_status):
if new_status not in {"pending", "waiting-pending",
"won", "lose", "waiting"}:
raise ValueError
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function todays_user
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def todays_user(secret_id='', user_id=''):
"""confirm the user id isn't used in other day
and return `User` object
Args:
secret_id (str): secret id of target user
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return error_response(1) # Invalid group member secret id
Avoid too many return
statements within this function. Open
return auth_error(4, 'error="invalid_request"')
Avoid too many return
statements within this function. Open
return error_response(3) # Login unsuccessful
Avoid too many return
statements within this function. Open
return resp
Avoid too many return
statements within this function. Open
return jsonify({"message": "Login Successful",
Avoid too many return
statements within this function. Open
return jsonify(result)
Avoid too many return
statements within this function. Open
return jsonify(result)
Avoid too many return
statements within this function. Open
return auth_error(0, 'error="invalid_token"')
Avoid too many return
statements within this function. Open
return auth_error(15, 'error="insufficient_scope"')
Avoid too many return
statements within this function. Open
return resp
Avoid too many return
statements within this function. Open
return auth_error(0, 'realm="id_disabled"')