merqlove/do_snapshot

View on GitHub

Showing 21 of 21 total issues

Class Command has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Command # rubocop:disable ClassLength
    include DoSnapshot::Helpers

    RESET_OPTIONS = [:droplets, :exclude, :only, :keep, :quiet,
                     :stop, :clean, :timeout, :shutdown, :delay,
Severity: Minor
Found in lib/do_snapshot/command.rb - About 2 hrs to fix

    Method stub_cleanup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def stub_cleanup
            @stubs ||= {}
            @stubs.each_pair do |_k, v|
              remove_request_stub(v) if v.class == WebMock::RequestStub
              next unless v.class == Array
    Severity: Minor
    Found in lib/do_snapshot/rspec/environment.rb - 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

              it 'with warning message' do
                stub_droplet(droplet_id)
                stub_image_destroy_fail(image_id)
                stub_image_destroy_fail(image_id2)
    
    
    Severity: Minor
    Found in lib/do_snapshot/rspec/adapter.rb and 1 other location - About 1 hr to fix
    lib/do_snapshot/rspec/adapter.rb on lines 224..240

    Duplicated Code

    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).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

              it 'with success' do
                stub_droplet(droplet_id)
                stub_image_destroy(image_id)
                stub_image_destroy(image_id2)
    
    
    Severity: Minor
    Found in lib/do_snapshot/rspec/adapter.rb and 1 other location - About 1 hr to fix
    lib/do_snapshot/rspec/adapter.rb on lines 243..259

    Duplicated Code

    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).

    Tuning

    This issue has a mass of 47.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method setup_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          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']
    Severity: Minor
    Found in lib/do_snapshot/cli.rb - About 55 mins 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

    Method stub_with_id_name has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def stub_with_id_name(request, id, name, fixture, type = :get, body = nil, status = 200) # rubocop:disable Metrics/ParameterLists
    Severity: Major
    Found in lib/do_snapshot/rspec/api_v2_helpers.rb - About 50 mins to fix

      Method fail_power_off has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def fail_power_off(e)
            return unless shutdown
            return unless e && e.id
            api.start_droplet(e.id)
          rescue
      Severity: Minor
      Found in lib/do_snapshot/command.rb - About 45 mins 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

      Method stub_with_id has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def stub_with_id(request, id, fixture, type = :get, body = nil, status = 200) # rubocop:disable Metrics/ParameterLists
      Severity: Minor
      Found in lib/do_snapshot/rspec/api_v2_helpers.rb - About 45 mins to fix

        Method dispatch_droplets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def dispatch_droplets
              droplets.each do |droplet|
                id = droplet.id.to_s
                next if exclude.include? id
                next unless only.empty? || only.include?(id)
        Severity: Minor
        Found in lib/do_snapshot/command.rb - About 45 mins 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

        Method stub_without_id has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def stub_without_id(request, fixture, type = :get, body = nil, status = 200)
        Severity: Minor
        Found in lib/do_snapshot/rspec/api_v2_helpers.rb - About 35 mins to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
          Severity: Minor
          Found in lib/do_snapshot/runner.rb - About 35 mins to fix

            Method stub_with_id_name has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def stub_with_id_name(request, id, name, fixture, status = 200)
            Severity: Minor
            Found in lib/do_snapshot/rspec/api_helpers.rb - About 35 mins to fix

              Method droplet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def droplet(id)
                      # noinspection RubyResolve
                      result = client.droplets.find(id: id)
                      fail DropletFindError, id unless result
                      result
              Severity: Minor
              Found in lib/do_snapshot/adapter/droplet_kit.rb - About 35 mins 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

              Method stop_droplet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def stop_droplet(droplet)
                    return true unless shutdown
                    logger.debug 'Shutting down droplet.'
                    api.stop_droplet(droplet.id) unless droplet.status.include? 'off'
                    true
              Severity: Minor
              Found in lib/do_snapshot/command.rb - About 35 mins 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

              Method assemble_gems has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def assemble_gems(target_dir = Dir.pwd)
                %x{ env BUNDLE_WITHOUT="development:test" bundle show }.split("\n").each do |line|
                  next unless line =~ /^  \* (.*?) \((.*?)\)/
                  next if GEM_BLACKLIST.include?(Regexp.last_match[1])
                  puts "vendoring: #{Regexp.last_match[1]}-#{Regexp.last_match[2]}"
              Severity: Minor
              Found in tasks/helpers/file.rb - About 35 mins 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

              Method handler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def handler(*response_codes, &block)
                    if response_codes.empty?
                      handlers[:any] = block
                    else
                      response_codes.each do |code|
              Severity: Minor
              Found in lib/do_snapshot/gem_ext/resource_kit.rb - About 25 mins 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

              Method default_handler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def default_handler(*response_codes, &block)
                    if response_codes.empty?
                      default_handlers[:any] = block
                    else
                      response_codes.each do |code|
              Severity: Minor
              Found in lib/do_snapshot/gem_ext/resource_kit.rb - About 25 mins 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                module ResourceCollectionFix # rubocop:disable Style/Documentation
                  def default_handler(*response_codes, &block)
                    if response_codes.empty?
                      default_handlers[:any] = block
                    else
              Severity: Minor
              Found in lib/do_snapshot/gem_ext/resource_kit.rb and 1 other location - About 20 mins to fix
              lib/do_snapshot/gem_ext/resource_kit.rb on lines 7..14

              Duplicated Code

              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).

              Tuning

              This issue has a mass of 28.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                module ActionFix # rubocop:disable Style/Documentation
                  def handler(*response_codes, &block)
                    if response_codes.empty?
                      handlers[:any] = block
                    else
              Severity: Minor
              Found in lib/do_snapshot/gem_ext/resource_kit.rb and 1 other location - About 20 mins to fix
              lib/do_snapshot/gem_ext/resource_kit.rb on lines 19..26

              Duplicated Code

              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).

              Tuning

              This issue has a mass of 28.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      describe '#delay' do
                        let(:delay) { 5 }
                        let(:instance) { api.new(delay: delay) }
                        it('with custom delay') { expect(instance.delay).to eq delay }
              Severity: Minor
              Found in lib/do_snapshot/rspec/adapter.rb and 1 other location - About 15 mins to fix
              lib/do_snapshot/rspec/adapter.rb on lines 17..20

              Duplicated Code

              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).

              Tuning

              This issue has a mass of 25.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language