Showing 2 of 2 total issues
Class Digitalocean
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Digitalocean < ComputeResource
alias_attribute :api_key, :password
alias_attribute :region, :url
has_one :key_pair, :foreign_key => :compute_resource_id, :dependent => :destroy
Method destroy_key_pair
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def destroy_key_pair
return unless key_pair
logger.info "removing DigitalOcean key #{key_pair.name}"
client.destroy_ssh_key(ssh_key.id) if ssh_key
key_pair.destroy
- 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"