mangroveorg/datawinners

View on GitHub
migration/from_previous_releases/couchmigrations.py

Summary

Maintainability
B
6 hrs
Test Coverage

Function migrate_01 has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

def migrate_01(managers, map_fun_project_docs, map_fun_raw_form_model_docs, map_fun_submission_docs):
    for manager in managers:
        initializer.run(manager)
        submissions = manager.database.query(map_fun_submission_docs)
        for submission in submissions:
Severity: Minor
Found in migration/from_previous_releases/couchmigrations.py - About 5 hrs 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

Avoid deeply nested control flow statements.
Open

                    for i, choice in enumerate(json_field['choices']):
                        choice['text']['en'] = choice['text']['eng']
                        del choice['text']['eng']
                        choice['val'] = chr(i + 97)
                        json_field['choices'][i] = choice
Severity: Major
Found in migration/from_previous_releases/couchmigrations.py - About 45 mins to fix

    There are no issues that match your filters.

    Category
    Status