merqlove/do_snapshot

View on GitHub

Showing 15 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

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

              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

              Severity
              Category
              Status
              Source
              Language