mangroveorg/datawinners

View on GitHub
datawinners/main/management/sync_changed_views.py

Summary

Maintainability
A
1 hr
Test Coverage

Function update_views has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def update_views(self, current_views, new_views, manager):
        for view_name, view_def in new_views.iteritems():
            if view_name not in current_views or self.has_view_contents_changed(current_views, new_views, view_name):
                map_function = (view_def['map'] if 'map' in view_def else None)
                reduce_function = (view_def['reduce'] if 'reduce' in view_def else None)
Severity: Minor
Found in datawinners/main/management/sync_changed_views.py - About 55 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_old_views has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def delete_old_views(self, current_views, new_views, manager):
        for current_view_name in current_views.keys():
            if current_view_name not in new_views:
                print 'Deleting view: %s from db: %s' % (current_view_name, manager.database.name)
                logging.info('Deleting view: %s from db: %s', current_view_name, manager.database.name)
Severity: Minor
Found in datawinners/main/management/sync_changed_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

There are no issues that match your filters.

Category
Status