api/routes/api.py
File api.py
has 376 lines of code (exceeds 250 allowed). Consider refactoring. Open
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 apply_lottery
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
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 results
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
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
Avoid too many return
statements within this function. Open
Open
return error_response(1) # Invalid group member secret id
Avoid too many return
statements within this function. Open
Open
return resp
Avoid too many return
statements within this function. Open
Open
return jsonify(result)
Avoid too many return
statements within this function. Open
Open
return jsonify(result)
Avoid too many return
statements within this function. Open
Open
return resp
Avoid too many return
statements within this function. Open
Open
return error_response(23)