Showing 1,567 of 3,608 total issues
Function has_higher_privileges_than
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def has_higher_privileges_than(self, user):
if self.is_ngo_admin() and (user.is_extended_user() or user.is_project_manager() or user.is_no_delete_pm()):
return True
if self.is_extended_user() and (user.is_project_manager() or user.is_no_delete_pm()):
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"
Further reading
Function remove_deleted_ds_from_project
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_deleted_ds_from_project(db_name):
logger = logging.getLogger(db_name)
try:
dbm = get_db_manager(db_name)
logger.info("starting data fix for " + db_name)
- 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 remove_reminders_for_deleted_questionnaires
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_reminders_for_deleted_questionnaires(db_name):
logger = logging.getLogger(db_name)
try:
dbm = get_db_manager(db_name)
org_id = datastore_org_id_map[db_name]
- 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 clean
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clean(self):
cleaned_data = self.cleaned_data
if 'email' in cleaned_data:
username = cleaned_data.get('email').strip()
if not len(username):
- 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_01
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def migrate_01(managers):
failed_managers = []
for manager in managers:
try:
print manager.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
Function edit_user
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def edit_user(request):
if request.method == 'GET':
profile = request.user.get_profile()
if profile.mobile_phone == 'Not Assigned':
profile.mobile_phone = ''
- 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 remove_deleted_questions_from_submissions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_deleted_questions_from_submissions(manager, form_model_id, deleted_question_codes):
if deleted_question_codes:
survey_responses = survey_responses_by_form_model_id(manager, form_model_id)
for survey_response in survey_responses:
for code in deleted_question_codes:
- 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 get_facet_response_for_choice_fields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_facet_response_for_choice_fields(query_with_criteria, choice_fields, form_model_id):
facet_results = []
for field in choice_fields:
field_name = es_questionnaire_field_name(field.code, form_model_id) + "_exact"
facet_response = query_with_criteria.facet(field_name, filtered=True).facet_counts()
- 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 build
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build(cls, manager, extension, default_parser=None, form_code=None, is_datasender=False, is_update=False):
channels = dict({".xls": Channel.XLS, ".xlsx": Channel.XLSX, ".csv": Channel.CSV})
try:
channel = channels[extension]
except KeyError:
- 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 registered_ds_count
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def registered_ds_count(request):
dbm = get_database_manager(request.user)
result = []
if request.user.is_ngo_admin() or request.user.is_extended_user():
rows = [row['value'] for row in dbm.load_all_rows_in_view('all_projects')]
- 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 questionnaire_preview
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def questionnaire_preview(request, project_id=None, sms_preview=False):
manager = get_database_manager(request.user)
if request.method == 'GET':
dashboard_page = settings.HOME_PAGE + "?deleted=true"
questionnaire = Project.get(manager, project_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
Function load_subject_type_with_projects
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def load_subject_type_with_projects(manager):
result = OrderedDict()
subject_types = get_unique_id_types(manager)
for subject_type in subject_types:
result.update({subject_type: []})
- 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 response_for_post_request
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def response_for_post_request(self, is_update=None):
questionnaire_form = self.form(self.request.POST)
quota_reached = is_quota_reached(self.request)
reporter_id = NGOUserProfile.objects.get(user=self.request.user).reporter_id
is_linked = self.reporter_id in self.questionnaire.data_senders
- 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 get_duplicates_filterable_fields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_duplicates_filterable_fields(fields, duplicates_filterable_fields, parent_code=None):
for field in fields:
if isinstance(field, UniqueIdField):
duplicates_filterable_fields.append(get_unique_id_field_details(field, parent_code))
if isinstance(field, FieldSet) and field.is_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 delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def delete(request, project_id):
dbm = get_database_manager(request.user)
questionnaire = Project.get(dbm, project_id)
dashboard_page = settings.HOME_PAGE + "?deleted=true"
if questionnaire.is_void():
- 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 in_group
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def in_group(user, group):
"""Returns True/False if the user is in the given group(s).
Usage::
{% if user|in_group:"Friends" %}
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 get_text_field_constraint_text
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_text_field_constraint_text(field):
if not is_empty(field.constraints):
length_constraint = field.constraints[0]
min = length_constraint.min
max = length_constraint.max
- 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 _split_repeated_data
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _split_repeated_data(repeated_data, row, row_index):
for repeated_datum in repeated_data:
if len(repeated_datum['data']) > row_index:
start_column_index = repeated_datum['row_index']
for index, val in enumerate(repeated_datum['data'][row_index]):
- 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_to_data_sender
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def send_email_to_data_sender(user, language_code, request=None, type="activation", organization=None):
site = get_current_site(request)
account_type = organization.account_type if organization else 'Pro SMS'
ctx_dict = {
'domain': site.domain,
- 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 import_submission
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def import_submission(self, request):
saved_entries, invalid_row_details, ignored_entries = [], [], []
total_submissions = 0
try:
- 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"