mangroveorg/datawinners

View on GitHub
migration/couch/release_9/3.2258_data_correction.py

Summary

Maintainability
C
1 day
Test Coverage

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)
Severity: Minor
Found in migration/couch/release_9/3.2258_data_correction.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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def is_void(d, ds):
    rows = d.view("entity_by_short_code/entity_by_short_code", key=[["reporter"], ds], include_docs=True)
    return rows.rows[0]["doc"]["void"]
Severity: Major
Found in migration/couch/release_9/3.2258_data_correction.py and 1 other location - About 2 hrs to fix
migration/couch/release_7/4.2258_data_correction.py on lines 15..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            try:
                project_data_senders = set(project_doc["doc"]["data_senders"])

                invalid_ds = project_data_senders.difference(all_data_senders)

Severity: Major
Found in migration/couch/release_9/3.2258_data_correction.py and 1 other location - About 2 hrs to fix
migration/couch/release_7/4.2258_data_correction.py on lines 32..44

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 52.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def get_all_active_data_senders(dbm):
    return [row.key[1] for row in
            dbm.view.by_short_codes(reduce=False, start_key=[["reporter"]], end_key=[["reporter"], {}])]
Severity: Major
Found in migration/couch/release_9/3.2258_data_correction.py and 1 other location - About 2 hrs to fix
migration/couch/release_7/4.2258_data_correction.py on lines 20..22

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 50.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

                    logger.info("Found invalid data senders in project : " + str(project_doc) + " " + str(invalid_ds))
Severity: Minor
Found in migration/couch/release_9/3.2258_data_correction.py and 1 other location - About 45 mins to fix
migration/couch/release_7/4.2258_data_correction.py on lines 39..39

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 35.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 24 locations. Consider refactoring.
Open

if __name__ == "__main__" and __package__ is None:
    sys.path.insert(0, ".")
Severity: Major
Found in migration/couch/release_9/3.2258_data_correction.py and 23 other locations - About 35 mins to fix
migration/couch/release_22/1.4282_migration_to_seperate_datasenders_and_contacts.py on lines 6..7
migration/couch/release_22/3.4333_migration_to_add_custom_groups_to_data_sender_mapping.py on lines 8..9
migration/couch/release_6_1/1.migration_set_required_true_on_questionnaire_fields.py on lines 6..7
migration/couch/release_6_1/2.migration_void_survey_response_with_no_values.py on lines 4..5
migration/couch/release_7/0.create_and_add_reporter_id_to_user_profile.py on lines 4..5
migration/couch/release_7/1.migration_to_remove_survey_response_with_delete_form_code.py on lines 4..5
migration/couch/release_7/2.migration_to_correct_survey_response_source_and_add_modified_by_field.py on lines 4..5
migration/couch/release_7/3.migration_to_create_feed_entry.py on lines 4..5
migration/couch/release_7/4.2258_data_correction.py on lines 7..8
migration/couch/release_7/5.migration_to_renumber_question_name_for_subject.py on lines 5..6
migration/couch/release_8/1.migration_to_create_search_indexes_for_subjects.py on lines 4..5
migration/couch/release_8/2.migration_add_geometry_data_for_harivola_fokontany.py on lines 4..5
migration/couch/release_8_1/1.migration_to_put_regex_validator_in_subject_short_code.py on lines 2..3
migration/couch/release_9/1.add_email_info_to_datasender_document.py on lines 3..4
migration/couch/release_9/1.migration_to_add_email_field_in_registration_form_model.py on lines 4..5
migration/couch/release_9/2.add_email_info_to_datasender_document.py on lines 4..5
migration/couch/release_9/4.migration_to_convert_uppercase_reporter_ids_to_lowercase.py on lines 4..5
migration/couch/release_9/5.2260_migration_to_update_constraints_for_datasender_registration.py on lines 5..6
migration/couch/release_9/6.2636_migration_to_add_location_field_to_admins.py on lines 3..4
migration/couch/release_9/7.migration_to_create_search_indxes_for_datasenders.py on lines 5..6
support/7.migration_to_aggregate_test_questionnaire_submissions.py on lines 4..5
support/delete_submission_mappings_for_all_indexes.py on lines 5..6
support/migration_to_change_case_of_shortcodes.py on lines 5..6

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 33.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

There are no issues that match your filters.

Category
Status