skymill/automated-ebs-snapshots

View on GitHub
automated_ebs_snapshots/snapshot_manager.py

Summary

Maintainability
A
2 hrs
Test Coverage

Function _ensure_snapshot has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def _ensure_snapshot(connection, volume, force):
    """ Ensure that a given volume has an appropriate snapshot

    :type connection: boto.ec2.connection.EC2Connection
    :param connection: EC2 connection object
Severity: Minor
Found in automated_ebs_snapshots/snapshot_manager.py - About 1 hr 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

Consider simplifying this complex logical expression.
Open

    if interval == 'hourly' and min_delta > 3600:
        _create_snapshot(volume)
    elif interval == 'daily' and min_delta > 3600*24:
        _create_snapshot(volume)
    elif interval == 'weekly' and min_delta > 3600*24*7:
Severity: Major
Found in automated_ebs_snapshots/snapshot_manager.py - About 40 mins to fix

    There are no issues that match your filters.

    Category
    Status