cloudamatic/mu

View on GitHub
modules/mu/providers/aws/server.rb

Summary

Maintainability
F
5 days
Test Coverage

Class has too many lines. [1926/1000]
Open

      class Server < MU::Cloud::Server

        # A list of block device names to use if we get a storage block that
        # doesn't declare one explicitly.
        # This probably fails on some AMIs. It's crude.
Severity: Minor
Found in modules/mu/providers/aws/server.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

File server.rb has 1941 lines of code (exceeds 1000 allowed). Consider refactoring.
Open

require 'net/ssh'
require 'net/ssh/multi'
require 'net/ssh/proxy/command'
autoload :OpenStruct, "ostruct"
autoload :Timeout, "timeout"
Severity: Major
Found in modules/mu/providers/aws/server.rb - About 3 days to fix

    Assignment Branch Condition size for toKitten is too high. [166.3/75]
    Open

          def toKitten(**_args)
            bok = {
              "cloud" => "AWS",
              "credentials" => @credentials,
              "cloud_id" => @cloud_id,
    Severity: Minor
    Found in modules/mu/providers/aws/server.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

    Class Server has 49 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class Server < MU::Cloud::Server
    
            # A list of block device names to use if we get a storage block that
            # doesn't declare one explicitly.
            # This probably fails on some AMIs. It's crude.
    Severity: Minor
    Found in modules/mu/providers/aws/server.rb - About 6 hrs to fix

      Assignment Branch Condition size for configureNetworking is too high. [96.92/75]
      Open

              def configureNetworking
                if !@config['static_ip'].nil?
                  if !@config['static_ip']['ip'].nil?
                    MU::Cloud::AWS::Server.associateElasticIp(@cloud_id, classic: @vpc.nil?, ip: @config['static_ip']['ip'], credentials: @credentials)
                  elsif !haveElasticIP?
      Severity: Minor
      Found in modules/mu/providers/aws/server.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

      Assignment Branch Condition size for createEc2Instance is too high. [87.46/75]
      Open

            def createEc2Instance
      
              instance_descriptor = {
                :image_id => @config["image_id"],
                :key_name => @deploy.ssh_key_name,
      Severity: Minor
      Found in modules/mu/providers/aws/server.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

      Assignment Branch Condition size for terminateInstance is too high. [85.5/75]
      Open

              def self.terminateInstance(instance: nil, noop: false, id: nil, onlycloud: false, region: MU.curRegion, deploy_id: MU.deploy_id, mu_name: nil, credentials: nil)
                if !id and !instance
                  MU.log "You must supply an instance handle or id to terminateInstance", MU::ERR
                  return
                end
      Severity: Minor
      Found in modules/mu/providers/aws/server.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

      Assignment Branch Condition size for postBoot is too high. [82.23/75]
      Open

            def postBoot(instance_id = nil)
              @cloud_id ||= instance_id
              _node, _config, deploydata = describe(cloud_id: @cloud_id)
      
              raise MuError, "Couldn't find instance #{@mu_name} (#{@cloud_id})" if !cloud_desc
      Severity: Minor
      Found in modules/mu/providers/aws/server.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

      Assignment Branch Condition size for groom is too high. [78.95/75]
      Open

              def groom
                MU::MommaCat.lock(@cloud_id+"-groom")
      
                # Make double sure we don't lose a cached mu_windows_name value.
                if windows? or !@config['active_directory'].nil?
      Severity: Minor
      Found in modules/mu/providers/aws/server.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 toKitten is too high. [32/30]
      Open

            def toKitten(**_args)
              bok = {
                "cloud" => "AWS",
                "credentials" => @credentials,
                "cloud_id" => @cloud_id,
      Severity: Minor
      Found in modules/mu/providers/aws/server.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.

      Avoid too many return statements within this method.
      Open

                return false
      Severity: Major
      Found in modules/mu/providers/aws/server.rb - About 30 mins to fix

        Use =~ in places where the MatchData returned by #match will not be used.
        Open

                        if e.message.match(/'deleting'/)
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb by rubocop

        This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

        Example:

        # bad
        do_something if str.match(/regex/)
        while regex.match('str')
          do_something
        end
        
        # good
        method(str =~ /regex/)
        return value unless regex =~ 'str'

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

                    MU::Cloud.availableClouds.each { |cloud|
                      next if cloud == "AWS"
                      foreign_types = (MU::Cloud.cloudClass(cloud).listInstanceTypes).values.first
                      if foreign_types.size == 1
                        foreign_types = foreign_types.values.first
        Severity: Major
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 3 hrs to fix
        modules/mu/providers/google/server.rb on lines 1468..1490

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

        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

                  s3_objs = [
                    "#{deploy.deploy_id}-secret",
                    "#{role_or_policy.mu_name}.pfx",
                    "#{role_or_policy.mu_name}.crt",
                    "#{role_or_policy.mu_name}.key",
        Severity: Major
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 1 hr to fix
        modules/mu/providers/aws/server.rb on lines 2291..2292

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

        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

                    s3_objs = ["#{deploy.deploy_id}-secret", "#{role.mu_name}.pfx", "#{role.mu_name}.crt", "#{role.mu_name}.key", "#{role.mu_name}-winrm.crt", "#{role.mu_name}-winrm.key"].map { |file| 
                      'arn:'+(MU::Cloud::AWS.isGovCloud?(region) ? "aws-us-gov" : "aws")+':s3:::'+MU::Cloud::AWS.adminBucketName(credentials)+'/'+file
        Severity: Major
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 1 hr to fix
        modules/mu/providers/aws/server.rb on lines 2319..2326

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

        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

                  if !server['generate_iam_role']
                    if !server['iam_role'] and server['cloud'] != "CloudFormation"
                      MU.log "Must set iam_role if generate_iam_role set to false", MU::ERR
                      ok = false
                    end
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 55 mins to fix
        modules/mu/providers/aws/server_pool.rb on lines 902..910

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

        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

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

                if !@mu_name.nil?
                  @config['mu_name'] = @mu_name
                  @mu_windows_name = @deploydata['mu_windows_name'] if @mu_windows_name.nil? and @deploydata
                else
                  if kitten_cfg.has_key?("basis")
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 50 mins to fix
        modules/mu/providers/google/server.rb on lines 63..73

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

        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

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

                  if use_cache
                    begin
                      win_admin_password = @groomer.getSecret(
                        vault: @config['windows_auth_vault']['vault'],
                        item: @config['windows_auth_vault']['item'],
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 40 mins to fix
        modules/mu/providers/google/server.rb on lines 1028..1037

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

        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

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

                    if nat_ssh_user.nil? and !nat_ssh_host.nil?
                      MU.log "#{@config["name"]} (#{MU.deploy_id}) is configured to use #{@config['vpc']} NAT #{nat_ssh_host}, but username isn't specified. Guessing root.", MU::ERR, details: caller
                      nat_ssh_user = "root"
                    end
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 2 other locations - About 35 mins to fix
        modules/mu/providers/azure/server.rb on lines 157..160
        modules/mu/providers/google/server.rb on lines 503..506

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

        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 6 locations. Consider refactoring.
        Open

                def arn
                  "arn:"+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+":ec2:"+@region+":"+MU::Cloud::AWS.credToAcct(@credentials)+":instance/"+@cloud_id
        Severity: Major
        Found in modules/mu/providers/aws/server.rb and 5 other locations - About 20 mins to fix
        modules/mu/providers/aws/cache_cluster.rb on lines 37..38
        modules/mu/providers/aws/firewall_rule.rb on lines 207..208
        modules/mu/providers/aws/msg_queue.rb on lines 73..74
        modules/mu/providers/aws/storage_pool.rb on lines 102..103
        modules/mu/providers/aws/vpc.rb on lines 222..223

        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

                      if @config["windows_auth_vault"].has_key?("sshd_password_field")
                        sshd_password = @groomer.getSecret(
                          vault: @config['windows_auth_vault']['vault'],
                          item: @config['windows_auth_vault']['item'],
                          field: @config["windows_auth_vault"]["sshd_password_field"]
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 20 mins to fix
        modules/mu/providers/aws/server.rb on lines 2084..2089

        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

                      if @config["windows_auth_vault"].has_key?("ec2config_password_field")
                        ec2config_password = @groomer.getSecret(
                          vault: @config['windows_auth_vault']['vault'],
                          item: @config['windows_auth_vault']['item'],
                          field: @config["windows_auth_vault"]["ec2config_password_field"]
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 20 mins to fix
        modules/mu/providers/aws/server.rb on lines 2092..2097

        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

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

                      if custom_append['skip_std']
                        script = erbfile
                      else
                        script = script+"\n"+erbfile
                      end
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 15 mins to fix
        modules/mu/cloud.rb on lines 571..577

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

        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::Cloud::AWS.createStandardTags(
                      creation.volume_id,
                      region: @region,
                      credentials: @credentials,
                      optional: @config['optional_tags'],
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 15 mins to fix
        modules/mu/providers/aws/server.rb on lines 2166..2173

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

        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::Cloud::AWS.createStandardTags(
                          iface.network_interface_id,
                          region: @region,
                          credentials: @credentials,
                          optional: @config['optional_tags'],
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb and 1 other location - About 15 mins to fix
        modules/mu/providers/aws/server.rb on lines 1322..1329

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

        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

        Do not suppress exceptions.
        Open

                    rescue Aws::EC2::Errors::InvalidAddressNotFound
        Severity: Minor
        Found in modules/mu/providers/aws/server.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

        private (on line 2023) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
        Open

                def self.getIAMProfile(myname, deploy, generated: true, role_name: nil, region: nil, credentials: nil, want_arn: false)
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb by rubocop

        This cop checks for private or protected access modifiers which are applied to a singleton method. These access modifiers do not make singleton methods private/protected. private_class_method can be used for that.

        Example:

        # bad
        
        class C
          private
        
          def self.method
            puts 'hi'
          end
        end

        Example:

        # good
        
        class C
          def self.method
            puts 'hi'
          end
        
          private_class_method :method
        end

        Example:

        # good
        
        class C
          class << self
            private
        
            def method
              puts 'hi'
            end
          end
        end

        Redundant use of Object#to_s in interpolation.
        Open

                          MU.log "Cannot create interface in subnet #{s.to_s} for #{@mu_name} due to AZ mismatch", MU::WARN
        Severity: Minor
        Found in modules/mu/providers/aws/server.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}"

        Useless assignment to variable - e.
        Open

                  rescue Errno::ENOENT => e
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb by rubocop

        This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

        assigned but unused variable - foo

        Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

        Example:

        # bad
        
        def some_method
          some_var = 1
          do_something
        end

        Example:

        # good
        
        def some_method
          some_var = 1
          do_something(some_var)
        end

        Do not suppress exceptions.
        Open

                  rescue Aws::EC2::Errors::InvalidAMIIDNotFound
        Severity: Minor
        Found in modules/mu/providers/aws/server.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

        Do not suppress exceptions.
        Open

                        rescue StandardError
        Severity: Minor
        Found in modules/mu/providers/aws/server.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

        Do not suppress exceptions.
        Open

                    rescue MU::Groomer::MuNoSuchSecret, MU::Groomer::RunError
        Severity: Minor
        Found in modules/mu/providers/aws/server.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 "Setting delete_on_termination flag to #{delete_on_termination.to_s} on #{@mu_name}'s #{device}"
        Severity: Minor
        Found in modules/mu/providers/aws/server.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}"

        Useless assignment to variable - e.
        Open

                  rescue Errno::ENOENT => e
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb by rubocop

        This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

        assigned but unused variable - foo

        Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

        Example:

        # bad
        
        def some_method
          some_var = 1
          do_something
        end

        Example:

        # good
        
        def some_method
          some_var = 1
          do_something(some_var)
        end

        end at 106, 8 is not aligned with if at 82, 22.
        Open

                end
        Severity: Minor
        Found in modules/mu/providers/aws/server.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)

        end at 503, 12 is not aligned with if at 496, 19.
        Open

                    end
        Severity: Minor
        Found in modules/mu/providers/aws/server.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)

        end at 2314, 10 is not aligned with if at 2286, 16.
        Open

                  end
        Severity: Minor
        Found in modules/mu/providers/aws/server.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)

        end at 336, 8 is not aligned with if at 334, 23.
        Open

                end
        Severity: Minor
        Found in modules/mu/providers/aws/server.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)

        end at 127, 6 is not aligned with def at 80, 8.
        Open

              end
        Severity: Minor
        Found in modules/mu/providers/aws/server.rb by rubocop

        This cop checks whether the end keywords of method definitions are aligned properly.

        Two modes are supported through the EnforcedStyleAlignWith configuration parameter. If it's set to start_of_line (which is the default), the end shall be aligned with the start of the line where the def keyword is. If it's set to def, the end shall be aligned with the def keyword.

        Example: EnforcedStyleAlignWith: startofline (default)

        # bad
        
        private def foo
                    end
        
        # good
        
        private def foo
        end

        Example: EnforcedStyleAlignWith: def

        # bad
        
        private def foo
                    end
        
        # good
        
        private def foo
                end

        There are no issues that match your filters.

        Category
        Status