Showing 7 of 33 total issues
Function get_all_members
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_all_members(token):
req_url = 'https://www.openhumans.org/api/direct-sharing' \
'/project/members/?access_token={}'.format(token)
members = requests.get(req_url).json()
if 'results' in members.keys():
- 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 download_zip_files
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def download_zip_files(user, group_id=None):
try:
project = Project.objects.get(user=user)
zip_subdir = str(uuid.uuid4())
zip_filename = '%s.zip' % zip_subdir
- 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 send_email
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def send_email(download_success, zipfile_url, contact_email, contact_name):
if download_success:
message = 'Hi ' + contact_name + '! Here is the file download link: ' + zipfile_url
else:
message = 'File Download Failed. Please try again'
- 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 batch_processing
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def batch_processing(request):
print(request.POST)
valid_filters = [
'file_count', 'id',
'sources_shared', 'groups', 'date_joined']
- 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 update_members
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_members(members, project):
# delete members from DB if not authorized any more
oh_ids_found = [int(member['project_member_id']) for member in members]
for db_member in project.projectmember_set.all():
if db_member.id not in oh_ids_found:
- 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 deeply nested control flow statements. Open
with open(new_filename, 'wb') as f:
f.write(file_response.content)
zip_path = os.path.join(
Function to_bool
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_bool(string, default):
"""Convert os environment variable to boolean."""
if string:
if string.lower() == 'true':
return True
- 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"