merqlove/do_snapshot

View on GitHub
lib/do_snapshot/command.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

    There are no issues that match your filters.

    Category
    Status