merqlove/do_snapshot

Very high overall complexity: 252

# -*- encoding : utf-8 -*-
require_relative 'adapter'

module DoSnapshot
  # Our commands live here :)
Found in DoSnapshot::Command - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Complex method in #create_snapshot

    def create_snapshot(droplet) # rubocop:disable MethodLength,Metrics/AbcSize
      fail_if_shutdown(droplet)

      logger.info "Start creating snapshot for droplet id: #{droplet.id} name: #{droplet.name}."

Found in DoSnapshot::Command - About 6 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #setup_config

      def setup_config # rubocop:disable Metrics/AbcSize
        DoSnapshot.configure do |config|
          config.logger = ::Logger.new(options['log']) if options['log']
          config.logger_level = Logger::DEBUG if config.verbose
          config.verbose = options['trace']
Found in DoSnapshot::CLI - About 2 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex class definition

# -*- encoding : utf-8 -*-
require 'thor'
require 'do_snapshot'
require_relative 'log'
require_relative 'mail'
Found in DoSnapshot::CLI - About 2 hrs to fix

    Complex method in #cleanup_snapshots

        def cleanup_snapshots(droplet, size) # rubocop:disable Metrics/AbcSize
          return unless size > keep
    
          warning_size(droplet.id, droplet.name, size)
    
    
    Found in DoSnapshot::Command - About 1 hr to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Join us for Code Climate
    Summit on July 19 in NYC.

    Tickets on sale now.