Method after_update
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def after_update(instance)
# This can get stale, so reload it -- if it exists
instance.deployment.reload if instance.deployment
if instance.state_changed?
event = Event.new(:source => instance, :event_time => DateTime.now,
- Read upRead up
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
Method update_quota
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def update_quota(state_from, state_to, an_instance)
pool = an_instance.pool
pool_family = pool.pool_family
user = an_instance.owner
provider_account = an_instance.provider_account
- Read upRead up
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
Method after_update
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def after_update(instance)
# This can get stale, so reload it -- if it exists
instance.deployment.reload if instance.deployment
if instance.state_changed?
event = Event.new(:source => instance, :event_time => DateTime.now,
Method update_quota
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_quota(state_from, state_to, an_instance)
pool = an_instance.pool
pool_family = pool.pool_family
user = an_instance.owner
provider_account = an_instance.provider_account
Avoid deeply nested control flow statements. Open
event4 = Event.new(:source => instance.deployment, :event_time => DateTime.now,
:status_code => "some_stopped", :summary => "Some instances are stopped",
:change_hash => instance.changes) if instance.deployment.events.lifetime.last{|e|e.status_code == :all_running}
Method after_save
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def after_save(instance)
if instance.state_changed? and instance.state == Instance::STATE_STOPPED
instance.instance_key.destroy if instance.instance_key
if instance.deployment and
- Read upRead up
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"