Showing 9 of 35 total issues
Function update
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def update(self):
response, answer_author, question_author = {'result': False}, 0, 0
try:
if len(self.answer_author()) > 0:
answer_author = self.answer_author()[0].get('user_id')
- 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
File models.py
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
Question Model
"""
import psycopg2
import psycopg2.extensions
Function post
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def post(self):
data = request.get_json(force=True)
data['user_id'] = session.get('user_id')
errors = validate_login_details(data)
if len(errors) > 0:
- 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 jwt_required
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def jwt_required(f):
""" Ensure jwt token is provided and valid
:param f: function to decorated
:return: decorated function
"""
- 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 migrate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def migrate(self):
con = psycopg2.connect(**self.config)
con.autocommit = True
cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
cur.execute("select * from pg_database where datname = %(database_name)s", {'database_name': self.database})
- 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 make_response(jsonify(response_object)), 404
Avoid too many return
statements within this function. Open
return make_response(jsonify(response_object)), 500
Avoid too many return
statements within this function. Open
return make_response(jsonify(response_object)), 400
Avoid too many return
statements within this function. Open
return make_response(jsonify(response_object)), 200