merqlove/do_snapshot

Complex class definition

# frozen_string_literal: true
module DoSnapshot
  module RSpec
    module Adapter # rubocop:disable Style/Documentation,Metrics/ModuleLength
      extend ::RSpec::Core::SharedContext
Found in DoSnapshot::RSpec::Adapter - About 2 wks to fix

    Very high overall complexity: 747

    # frozen_string_literal: true
    module DoSnapshot
      module RSpec
        module Adapter # rubocop:disable Style/Documentation,Metrics/ModuleLength
          extend ::RSpec::Core::SharedContext
    Found in DoSnapshot::RSpec::Adapter - About 6 days 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

    Very high overall complexity: 252

    # -*- encoding : utf-8 -*-
    # frozen_string_literal: true
    require_relative 'adapter'
    
    module DoSnapshot
    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 class definition

    # frozen_string_literal: true
    module DoSnapshot
      module RSpec
        module Environment # rubocop:disable Style/Documentation
          extend ::RSpec::Core::SharedContext
    Found in DoSnapshot::RSpec::Environment - About 1 day to fix

      Similar code found in 1 other location

      # frozen_string_literal: true
      module DoSnapshot
        module RSpec
          module Adapter # rubocop:disable Style/Documentation,Metrics/ModuleLength
            extend ::RSpec::Core::SharedContext
      Found in DoSnapshot::RSpec::Adapter and 1 other location - About 7 hrs to fix
      lib/do_snapshot/rspec/adapter.rb on lines 243..260

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Refactorings

      Further Reading

      Similar code found in 1 other location

      # frozen_string_literal: true
      module DoSnapshot
        module RSpec
          module Adapter # rubocop:disable Style/Documentation,Metrics/ModuleLength
            extend ::RSpec::Core::SharedContext
      Found in DoSnapshot::RSpec::Adapter and 1 other location - About 7 hrs to fix
      lib/do_snapshot/rspec/adapter.rb on lines 224..241

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      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 class definition

      # frozen_string_literal: true
      module DoSnapshot
        module RSpec
          module UriHelpers # rubocop:disable Style/Documentation
            extend ::RSpec::Core::SharedContext
      Found in DoSnapshot::RSpec::UriHelpers - About 4 hrs to fix

        Similar code found in 1 other location

        # frozen_string_literal: true
        module DoSnapshot
          module RSpec
            module Adapter # rubocop:disable Style/Documentation,Metrics/ModuleLength
              extend ::RSpec::Core::SharedContext
        Found in DoSnapshot::RSpec::Adapter and 1 other location - About 4 hrs to fix
        lib/do_snapshot/rspec/adapter.rb on lines 11..15

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Refactorings

        Further Reading

        Similar code found in 1 other location

        # frozen_string_literal: true
        module DoSnapshot
          module RSpec
            module Adapter # rubocop:disable Style/Documentation,Metrics/ModuleLength
              extend ::RSpec::Core::SharedContext
        Found in DoSnapshot::RSpec::Adapter and 1 other location - About 4 hrs to fix
        lib/do_snapshot/rspec/adapter.rb on lines 17..21

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Refactorings

        Further Reading

        Similar code found in 1 other location

        # frozen_string_literal: true
        require 'resource_kit'
        require 'forwardable'
        
        # TODO: Remove after `resource_kit` gem update.
        Found in ResourceKit::ActionFix and 1 other location - About 4 hrs to fix
        lib/do_snapshot/gem_ext/resource_kit.rb on lines 7..14

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Refactorings

        Further Reading

        Similar code found in 1 other location

        # frozen_string_literal: true
        require 'resource_kit'
        require 'forwardable'
        
        # TODO: Remove after `resource_kit` gem update.
        Found in ResourceKit::ActionFix and 1 other location - About 4 hrs to fix
        lib/do_snapshot/gem_ext/resource_kit.rb on lines 19..26

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Refactorings

        Further Reading

        Complex class definition

        # frozen_string_literal: true
        module DoSnapshot
          module RSpec
            module ApiV2Helpers # rubocop:disable Style/Documentation,Metrics/ModuleLength
              extend ::RSpec::Core::SharedContext
        Found in DoSnapshot::RSpec::ApiV2Helpers - About 3 hrs to fix

          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 -*-
          # frozen_string_literal: true
          require 'thor'
          require 'do_snapshot'
          require_relative 'log'
          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