cloudamatic/mu

View on GitHub
modules/mu/mommacat/daemon.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Assignment Branch Condition size for groomNode is too high. [173/75]
Open

    def groomNode(cloud_id, name, type, mu_name: nil, reraise_fail: false, sync_wait: true)
      if cloud_id.nil?
        raise GroomError, "MU::MommaCat.groomNode requires a {MU::Cloud::Server} object"
      end
      if name.nil? or name.empty?
Severity: Minor
Found in modules/mu/mommacat/daemon.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for groomNode is too high. [32/30]
Open

    def groomNode(cloud_id, name, type, mu_name: nil, reraise_fail: false, sync_wait: true)
      if cloud_id.nil?
        raise GroomError, "MU::MommaCat.groomNode requires a {MU::Cloud::Server} object"
      end
      if name.nil? or name.empty?
Severity: Minor
Found in modules/mu/mommacat/daemon.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for cleanTerminatedInstances is too high. [75.77/75]
Open

    def self.cleanTerminatedInstances(debug = false)
      loglevel = debug ? MU::NOTICE : MU::DEBUG
      MU::MommaCat.lock("clean-terminated-instances", false, true)
      MU.log "Checking for harvested instances in need of cleanup", loglevel
      parent_thread_id = Thread.current.object_id
Severity: Minor
Found in modules/mu/mommacat/daemon.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Avoid too many return statements within this method.
Open

      return
Severity: Major
Found in modules/mu/mommacat/daemon.rb - About 30 mins to fix

    Use each_value instead of values.each.
    Open

                deploy.kittens["servers"].values.each { |nodeclasses|
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks for uses of each_key and each_value Hash methods.

    Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

    Example:

    # bad
    hash.keys.each { |k| p k }
    hash.values.each { |v| p v }
    hash.each { |k, _v| p k }
    hash.each { |_k, v| p v }
    
    # good
    hash.each_key { |k| p k }
    hash.each_value { |v| p v }

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

              MU.log "#{mu_name} is already being groomed, skipping", MU::NOTICE
              MU::MommaCat.unlockAll
              if !MU::MommaCat.locks.nil? and MU::MommaCat.locks.size > 0
                puts "------------------------------"
                puts "Open flock() locks:"
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb and 1 other location - About 40 mins to fix
    modules/mu/mommacat/daemon.rb on lines 130..139

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

    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

              MU.log "#{mu_name} is still in mid-creation, skipping", MU::NOTICE
              MU::MommaCat.unlockAll
              if !MU::MommaCat.locks.nil? and MU::MommaCat.locks.size > 0
                puts "------------------------------"
                puts "Open flock() locks:"
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb and 1 other location - About 40 mins to fix
    modules/mu/mommacat/daemon.rb on lines 143..152

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

    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

          Thread.handle_interrupt(Net::SSH::Disconnect => :never) {
            begin
              Thread.handle_interrupt(Net::SSH::Disconnect => :immediate) {
                MU.log "(Probably harmless) Caught a Net::SSH::Disconnect in #{Thread.current.inspect}", MU::DEBUG, details: Thread.current.backtrace
              }
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb and 1 other location - About 30 mins to fix
    modules/mu/cloud/ssh_sessions.rb on lines 29..36

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

    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

            cmd = %Q{bundle exec thin --threaded --daemonize --port #{MU.mommaCatPort} --pid #{daemonPidFile} --log #{daemonLogFile} --ssl --ssl-key-file #{MU.muCfg['ssl']['key']} --ssl-cert-file #{MU.muCfg['ssl']['cert']} --ssl-disable-verify --tag mu-momma-cat -R mommacat.ru start}
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb and 1 other location - About 20 mins to fix
    modules/mu/mommacat/daemon.rb on lines 323..323

    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

            cmd = %Q{thin --threaded --daemonize --port #{MU.mommaCatPort} --pid #{daemonPidFile} --log #{daemonLogFile} --ssl --ssl-key-file #{MU.muCfg['ssl']['key']} --ssl-cert-file #{MU.muCfg['ssl']['cert']} --ssl-disable-verify --tag mu-momma-cat -R mommacat.ru start}
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb and 1 other location - About 20 mins to fix
    modules/mu/mommacat/daemon.rb on lines 325..325

    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

    Redundant use of Object#to_s in interpolation.
    Open

            MU.log "Stopping Momma Cat with pid #{pid.to_s}"
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks for string conversion in string interpolation, which is redundant.

    Example:

    # bad
    
    "result is #{something.to_s}"

    Example:

    # good
    
    "result is #{something}"

    end at 307, 8 is not aligned with if at 304, 7.
    Open

            end
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks whether the end keywords are aligned properly.

    Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

    If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

    If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

    If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

    Example: EnforcedStyleAlignWith: keyword (default)

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
               end

    Example: EnforcedStyleAlignWith: variable

    # bad
    
    variable = if true
        end
    
    # good
    
    variable = if true
    end

    Example: EnforcedStyleAlignWith: startofline

    # bad
    
    variable = if true
        end
    
    # good
    
    puts(if true
    end)

    Do not suppress exceptions.
    Open

            rescue Errno::ENOENT
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks for rescue blocks with no body.

    Example:

    # bad
    
    def some_method
      do_something
    rescue
      # do nothing
    end

    Example:

    # bad
    
    begin
      do_something
    rescue
      # do nothing
    end

    Example:

    # good
    
    def some_method
      do_something
    rescue
      handle_exception
    end

    Example:

    # good
    
    begin
      do_something
    rescue
      handle_exception
    end

    Redundant use of Object#to_s in interpolation.
    Open

            MU.log "Momma Cat with pid #{pid.to_s} stopped", MU::DEBUG, details: daemonPidFile
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks for string conversion in string interpolation, which is redundant.

    Example:

    # bad
    
    "result is #{something.to_s}"

    Example:

    # good
    
    "result is #{something}"

    Redundant use of Object#to_s in interpolation.
    Open

              MU.log "Momma Cat running with pid #{pid.to_s}", (@@notified_on_pid[pid] ? MU::DEBUG : MU::INFO) # shush
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks for string conversion in string interpolation, which is redundant.

    Example:

    # bad
    
    "result is #{something.to_s}"

    Example:

    # good
    
    "result is #{something}"

    File.exists? is deprecated in favor of File.exist?.
    Open

          File.unlink(daemonPidFile) if File.exists?(daemonPidFile)
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks for uses of the deprecated class method usages.

    Example:

    # bad
    
    File.exists?(some_path)

    Example:

    # good
    
    File.exist?(some_path)

    Do not suppress exceptions.
    Open

            rescue Errno::ESRCH
    Severity: Minor
    Found in modules/mu/mommacat/daemon.rb by rubocop

    This cop checks for rescue blocks with no body.

    Example:

    # bad
    
    def some_method
      do_something
    rescue
      # do nothing
    end

    Example:

    # bad
    
    begin
      do_something
    rescue
      # do nothing
    end

    Example:

    # good
    
    def some_method
      do_something
    rescue
      handle_exception
    end

    Example:

    # good
    
    begin
      do_something
    rescue
      handle_exception
    end

    There are no issues that match your filters.

    Category
    Status