cloudamatic/mu

View on GitHub

Showing 255 of 2,705 total issues

Avoid deeply nested control flow statements.
Open

              if wait >= 30
                MU.log "User #{user} has been created in LDAP, but local system can't see it. Are PAM/LDAP configured correctly?", MU::ERR
                return false
              end
Severity: Major
Found in modules/mu/master/ldap.rb - About 45 mins to fix

    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

                    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

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

            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 public
                                  { "Fn::GetAtt" => [@dependencies["server"][dnsrec['target']].cloudobj.cfm_name, "PublicDnsName"] }
                                else
                                  { "Fn::GetAtt" => [@dependencies["server"][dnsrec['target']].cloudobj.cfm_name, "PrivateDnsName"] }
                                end
            Severity: Major
            Found in modules/mu/providers/cloudformation/dnszone.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 policy['target_tracking_configuration']["preferred_target_group"] and
                                       lb["targetgroups"][policy['target_tracking_configuration']["preferred_target_group"]]
                                      lb["arn"].split(/:/)[5].sub(/^loadbalancer\//, "")+"/"+lb["targetgroups"][policy['target_tracking_configuration']["preferred_target_group"]].split(/:/)[5]
                                    else
                                      if policy['target_tracking_configuration']["preferred_target_group"]
                Severity: Major
                Found in modules/mu/providers/aws/server_pool.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

                                    if sib_by_name.size == 1
                                      @vpc = sib_by_name.values.first
                                      MU.log "Single VPC match for #{self}", loglevel, details: @vpc.to_s
                                    else
                    # XXX ok but this is the wrong place for this really the config parser needs to sort this out somehow
                    Severity: Major
                    Found in modules/mu/cloud/resource_base.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

                                          server.cloud_desc.public_dns_name.empty? ? server.cloud_desc.private_dns_name : server.cloud_desc.public_dns_name
                        Severity: Major
                        Found in modules/mu/mommacat/naming.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if disable
                                          attr[:userAccountControl] = (attr[:userAccountControl].to_i & AD_PW_ATTRS['disable']).to_s
                                        end
                          Severity: Major
                          Found in modules/mu/master/ldap.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

                                          rescue StandardError => e
                                            MU.log "Failed to fetch #{cryptfile} from Cloud Storage bucket #{MU.adminBucketName}", MU::ERR, details: e.inspect
                                            %x{/bin/dd if=/dev/urandom of=#{temp_dev} bs=1M count=1 > /dev/null 2>&1}
                                            raise e
                              Severity: Major
                              Found in modules/mu/master.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

                                            elsif cfg.id
                                              littermate = deploy.findLitterMate(type: cfg.type, cloud_id: cfg.id, habitat: cfg.habitat)
                                              if littermate and littermate.config['name']
                                                hashcfg['name'] = littermate.config['name']
                                                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

                                                    unless policy['type']
                                                      MU.log "You must specify a 'type' when 'policy_type' is set to 'StepScaling'", 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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language