Showing 1,567 of 3,608 total issues
Function create_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_type(request):
success = False
form = EntityTypeForm(request.POST)
if form.is_valid():
entity_name = form.cleaned_data["entity_type_regex"]
- 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 _convert_contacts_to_datasenders
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _convert_contacts_to_datasenders(self, contact_short_codes, manager, request):
datasender_id_email_map = {}
for contact_short_code in contact_short_codes:
datasender = contact_by_short_code(manager, contact_short_code)
if datasender.is_contact:
- 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 create_poll
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_poll(request):
if request.method == 'POST':
organization = get_organization(request)
if not _is_smsc_configured(organization):
return HttpResponse(json.dumps({'success': False,
- 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 log_edit_action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def log_edit_action(old_survey_response, new_survey_response, request, project_name, form_model):
differences = new_survey_response.differs_from(old_survey_response)
diff_dict = {}
changed_answers = deepcopy(differences.changed_answers)
if differences.changed_answers:
- 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 add_imported_data_sender_to_trial_organization
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_imported_data_sender_to_trial_organization(org_id, imported_datasenders, all_data_senders, index=0):
organization = Organization.objects.get(org_id=org_id)
if organization.in_trial_mode:
mobile_number_index = index
for ds in all_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_filterable_fields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_filterable_fields(fields, filterable_fields, parent_code=None):
for field in fields:
field_detials = get_filterable_field_details(field, filterable_fields, parent_code)
if field_detials:
filterable_fields.append(field_detials)
- 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 _rotating
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _rotating(self):
for i in range(self.backupCount - 1, 0, -1):
sfn = "%s.%d.%s" % (self.baseFilename, i, self.compress_mode)
dfn = "%s.%d.%s" % (self.baseFilename, i + 1, self.compress_mode)
if os.path.exists(sfn):
- 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
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove(self, parent_node, node, xform, old_field, activity_log_detail):
if isinstance(old_field, FieldSet):
return
if node is not None:
- 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 create_new_submission_response
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_new_submission_response(self):
try:
if not is_authorized_for_questionnaire(self.manager, self.request_user, self.request.POST['form_code']):
return HttpResponse(status=403)
if self.organization.in_trial_mode:
- 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_from_madagascar_ocha_wgs84_shp_file
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def load_from_madagascar_ocha_wgs84_shp_file(root_directory, verbose=True):
for root, dirs, files in os.walk(root_directory):
files = glob.glob(root + '/*.shp')
for file in files:
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"
Further reading
Function convert_excel_to_dict
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def convert_excel_to_dict(file_name=None, file_content=None, file_type='xlsx'):
book = pe.get_book(file_name=file_name, file_content=file_content, file_type=file_type)
excel_as_dict = OrderedDict()
for sheet in book:
records = []
- 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
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def edit(self, node, old_field, new_field, old_xform, new_xform, activity_log_detail):
bind_node = old_xform.bind_node(node)
if bind_node is not None and new_field.relevant != old_field.relevant:
if new_field.relevant:
- 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 _create_details_for_edit_info
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _create_details_for_edit_info(new_data_dict, old_data, questionnaire):
details = dict()
for key, value in new_data_dict.iteritems():
if key in old_data and key not in {"intro", "meta", "form_code"}:
if new_data_dict[key] != old_data[key]:
- 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_all_project_for_user
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_all_project_for_user(user, get_project_info_function=default_get_project_info, dbm=None):
if user.get_profile().reporter:
return [get_project_info_function(dbm, row['value'])
for row in get_all_projects(get_database_manager(user), user.get_profile().reporter_id)
if row['value'].get('is_poll',False) is False]
- 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 create_all_mappings
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_all_mappings(dbm):
logger = logging.getLogger(dbm.database_name)
for row in dbm.load_all_rows_in_view('questionnaire'):
try:
if row['value']['is_registration_model']:
- 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_header_dict
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_header_dict(self):
header_dict = OrderedDict()
header_dict.update(self.update_static_header_info())
def key_attribute(field):
- 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 populate_contact_index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def populate_contact_index(dbm):
rows = dbm.database.iterview('datasender_by_mobile/datasender_by_mobile', 100, reduce=False, include_docs=True)
actions = []
es = get_elasticsearch_handle()
for row in rows:
- 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_report_filters
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_report_filters(dbm, config, questionnaire):
if not hasattr(config, "filters") or not config.filters:
return {
"idnr_filters": [],
"date_filters": []
- 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 handle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
log_folder = "/var/tmp/media_usage"
if not os.path.exists(log_folder):
os.makedirs(log_folder)
log_file_name = "%s" % datetime.datetime.now().strftime('media_usage_%H_%M_%d_%m_%Y.log')
- 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 format_fieldset_values_for_representation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def format_fieldset_values_for_representation(entry, field_set, submission_id):
formatted_value = ''
if entry is not None:
data_to_iterate = entry
if not isinstance(entry, list):
- 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"