mangroveorg/datawinners

View on GitHub

Showing 1,567 of 3,608 total issues

Function physical_inventory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def physical_inventory(year, commodities):
    for warehouse in Warehouse.objects.all():
        for food in commodities:
            for pl in PackingList.objects.all():
                PhysicalInventorySheetBuilder().build(warehouse.q5, year, 6, food, pl.q1).save()
Severity: Minor
Found in datawinners/custom_reports/crs/test_data.py - About 25 mins to fix

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):
Severity: Minor
Found in datawinners/accountmanagement/admin.py - About 25 mins to fix

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 custom_password_reset_confirm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def custom_password_reset_confirm(request, uidb36=None, token=None, set_password_form=SetPasswordForm,
                                  template_name='registration/datasender_activate.html'):
    response = password_reset_confirm(request, uidb36=uidb36, token=token, set_password_form=set_password_form,
                                      template_name=template_name)
    if request.method == 'POST' and type(response) == HttpResponseRedirect:
Severity: Minor
Found in datawinners/accountmanagement/views.py - About 25 mins to fix

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_exception_message_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_exception_message_for(exception, channel=None, formatter=default_formatter):
    ex_type = type(exception)
    if channel is not None:
        message_dict = exception_messages.get(ex_type)
        if message_dict is None:
Severity: Minor
Found in datawinners/messageprovider/message_handler.py - About 25 mins to fix

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 undelete_datasenders_for_organization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def undelete_datasenders_for_organization(db_name):
    logger = logging.getLogger(db_name)
    try:
        dbm = get_db_manager(db_name)
        for reporter in get_all_entities_include_voided(dbm, [REPORTER_ENTITY_TYPE]):
Severity: Minor
Found in migration/couch/release_14/2.4060_migration_to_undelete_datasenders.py - About 25 mins to fix

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 renumber_fields_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def renumber_fields_name(form_model):
    data_to_restore, max_question_names, existing_names = [], [], {}
    data_length = 0
    for field in form_model.fields:
        if field.name.startswith("Question"):

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:
Severity: Minor
Found in datawinners/entity/view/all_datasenders.py - About 25 mins to fix

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():
Severity: Minor
Found in datawinners/project/views/submission_views.py - About 25 mins to fix

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:
Severity: Minor
Found in datawinners/entity/helper.py - About 25 mins to fix

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)
Severity: Minor
Found in datawinners/project/views/submission_views.py - About 25 mins to fix

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,
Severity: Minor
Found in datawinners/entity/import_data.py - About 25 mins to fix

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: []})
Severity: Minor
Found in datawinners/entity/subjects.py - About 25 mins to fix

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():
Severity: Minor
Found in datawinners/project/views/submission_views.py - About 25 mins to fix

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_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"]
Severity: Minor
Found in datawinners/entity/views.py - About 25 mins to fix

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]):
Severity: Minor
Found in datawinners/project/submission/export.py - About 25 mins to fix

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:
Severity: Minor
Found in datawinners/project/views/submission_views.py - About 25 mins to fix

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')]
Severity: Minor
Found in datawinners/project/views/registered_datasenders.py - About 25 mins to fix

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()
Severity: Minor
Found in datawinners/project/views/submission_views.py - About 25 mins to fix

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,
Severity: Minor
Found in datawinners/project/create_poll.py - About 25 mins to fix

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
Severity: Minor
Found in datawinners/project/questionnaire_fields.py - About 25 mins to fix

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

Severity
Category
Status
Source
Language