cloudamatic/mu

View on GitHub

Showing 255 of 2,705 total issues

Method validate has a Cognitive Complexity of 78 (exceeds 75 allowed). Consider refactoring.
Open

      def self.validate(db, configurator)
        ok = true
        read_replicas = []
        cluster_nodes = []

Severity: Minor
Found in modules/mu/config/database.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

Avoid deeply nested control flow statements.
Open

                if public
                  # Make sure we have a public IP address to register. Use the private one if we don't
                  server.cloud_desc.public_ip_address ? server.cloud_desc.public_ip_address : server.cloud_desc.private_ip_address
                else
                  # If we specifically requested to register the private IP lets use that
Severity: Major
Found in modules/mu/mommacat/naming.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                      raise MuError, "Couldn't find #{dnsrec['mu_type']} #{dnsrec["target"]}" if found.nil? || found.empty?
    Severity: Major
    Found in modules/mu/providers/cloudformation/dnszone.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  slack_path_str += "#{preposition} \*"+path.join(" ⇨ ")+"\*" if path.size > 0
      Severity: Major
      Found in modules/mu/adoption.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        MU.log "No base image for platform #{platform} in cloud #{cloud} region #{region} found", MU::WARN if !quiet
        Severity: Major
        Found in modules/mu/cloud/machine_images.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        ok = false if !insertKitten(siblingvpc, "vpcs", overwrite: overwrite)
          Severity: Major
          Found in modules/mu/config.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                              my_cidr = nil if my_cidr.to_s.match(/^10\.255\./)
            Severity: Major
            Found in modules/mu/config/vpc.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            if mu_acct
                              attr[:userAccountControl] = (attr[:userAccountControl].to_i & AD_PW_ATTRS['pwdNeverExpires']).to_s
                            end
              Severity: Major
              Found in modules/mu/master/ldap.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                  if step["adjustment"] >= 1 && policy["estimated_instance_warmup"].nil?
                                    MU.log "You must specify 'estimated_instance_warmup' when 'policy_type' is set to 'StepScaling' and adding capacity", MU::ERR
                                    ok = false
                                  end
                Severity: Major
                Found in modules/mu/providers/aws/server_pool.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                    elsif dnsrec["type"] == "A"
                                      if public
                                        { "Fn::GetAtt" => [@dependencies["server"][dnsrec['target']].cloudobj.cfm_name, "PublicIp"] }
                                      else
                                        { "Fn::GetAtt" => [@dependencies["server"][dnsrec['target']].cloudobj.cfm_name, "PrivateIp"] }
                  Severity: Major
                  Found in modules/mu/providers/cloudformation/dnszone.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                      raise MuError, "Couldn't find #{dnsrec['mu_type']} #{dnsrec["target"]}" if found.nil? || found.empty?
                    Severity: Major
                    Found in modules/mu/providers/cloudformation/dnszone.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  path.pop if path.last == name
                      Severity: Major
                      Found in modules/mu/adoption.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                          if @config['basis'] and !unq.nil? and !unq.empty?
                                            @mu_windows_name = @deploy.getResourceName(@config['name'], max_length: 15, need_unique_string: true, use_unique_string: unq, reuse_unique_string: true)
                                          else
                                            @mu_windows_name = @deploy.getResourceName(@config['name'], max_length: 15, need_unique_string: true)
                                          end
                        Severity: Major
                        Found in modules/mu/cloud/resource_base.rb - About 45 mins to fix

                          Method create has a Cognitive Complexity of 78 (exceeds 75 allowed). Consider refactoring.
                          Open

                                  def create
                                    # RDS is picky, we can't just use our regular node names for things
                                    # like the default schema or username. And it varies from engine to
                                    # engine.
                                    basename = @config["name"].to_s
                          Severity: Minor
                          Found in modules/mu/providers/cloudformation/database.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

                          Avoid deeply nested control flow statements.
                          Open

                                          if File.exist?(example_path)
                                            example = "#\n# Examples:\n#\n"
                                            # XXX these variables are all parameters from the BoKs in
                                            # modules/tests. A really clever implementation would read
                                            # and parse them to get default values, perhaps, instead of
                          Severity: Major
                          Found in modules/mu/config/doc_helpers.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if ![:removed].include?(tier[:action])
                                          myreport["slack"] += ". New #{tier[:field] ? "`"+tier[:field]+"`" : :value}: \*#{tier[:value]}\*"
                                        else
                                          myreport["slack"] += " (was \*#{tier[:value]}\*)"
                                        end
                            Severity: Major
                            Found in modules/mu/adoption.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          hashcfg.delete("id") if hashcfg["name"]
                              Severity: Major
                              Found in modules/mu/adoption.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                if @type == "folders"
                                MU.log "would assign name '#{@obj.mu_name}' in ref to this folder if I were feeling aggressive", MU::WARN, details: self.to_h
                                end
                                Severity: Major
                                Found in modules/mu/config/ref.rb - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                  if used_uids.include?(change_uid)
                                                    raise MuLDAPError, "Uid #{change_uid} is unavailable, cannot allocate to user #{user}"
                                                  end
                                  Severity: Major
                                  Found in modules/mu/master/ldap.rb - About 45 mins to fix

                                    Method generate_dummy_object has 11 arguments (exceeds 10 allowed). Consider refactoring.
                                    Open

                                        def self.generate_dummy_object(type, cloud, name, mu_name, cloud_id, desc, region, habitat, tag_value, calling_deploy, credentials)
                                    Severity: Major
                                    Found in modules/mu/mommacat/search.rb - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language