cloudamatic/mu

View on GitHub

Showing 255 of 2,705 total issues

Avoid deeply nested control flow statements.
Open

                  if @dependencies.has_key?(dnsrec['mu_type']) && dnsrec['deploy_id'].nil?
                    @dependencies[dnsrec['mu_type']][dnsrec['target']].deploydata['endpoint']
                  elsif dnsrec['deploy_id']
                    found = MU::MommaCat.findStray("AWS", "database", deploy_id: dnsrec["deploy_id"], mu_name: dnsrec["target"], region: @region)
                    raise MuError, "Couldn't find #{dnsrec['mu_type']} #{dnsrec["target"]}" if found.nil? || found.empty?
Severity: Major
Found in modules/mu/providers/aws/dnszone.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if type['level'] == node['glusterfs']['server']['raid_level'] and type['spare'] == node['glusterfs']['server']['raid_spare_vol'] and node['glusterfs']['server']['devices'.size] >= type['min_devcies']
                  spare_device = node['glusterfs']['server']['devices'].pop
                  raid_with_spare(node['glusterfs']['server']['raid_dev'], node['glusterfs']['server']['raid_level'], node['glusterfs']['server']['devices'].size, node['glusterfs']['server']['devices'].join(" "), spare_device)
                end
    Severity: Major
    Found in cookbooks/mu-glusterfs/recipes/server.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      if resp
                        MU.log "Deleting organization role #{resp.name}"
                        if !noop
                          MU::Cloud::Google.iam(credentials: credentials).delete_organization_role(id)
                        end
      Severity: Major
      Found in modules/mu/providers/google/role.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                              rescue Aws::EFS::Errors::BadRequest => e
                                MU.log "Mount target #{mp.mount_target_id} already deleted", MU::NOTICE if e.to_s.start_with?("invalid mount target ID")
        Severity: Major
        Found in modules/mu/providers/aws/storage_pool.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if re.search(regex, results[ip]) or results[ip] == dom:
                                  print("Blocking IP "+ip+". Request from '"+results[ip]+"' matched blacklist entry. LB log was: "+key)
                                  addIPToWAFBlacklist(ip)
              return True
          Severity: Major
          Found in extras/lambda_waf_domain_blacklist.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if acct_num.to_s == name.to_s
                            @@acct_to_profile_map[name.to_s] = cfg
                            return name_only ? name.to_s : cfg
                          end
            Severity: Major
            Found in modules/mu/providers/aws.rb - About 45 mins to fix

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

                      def toKitten(**_args)
              
                        bok = {
                          "cloud" => "Google",
                          "project" => @config['project'],
              Severity: Minor
              Found in modules/mu/providers/google/container_cluster.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

                                next if e.message.match(/notFound/)
              Severity: Major
              Found in modules/mu/providers/google/role.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                rescue ::Google::Apis::ClientError => e
                #MU.log e.message, MU::ERR, details: id
                #next
                                  next if e.message.match(/notFound/)
                                  raise e
                Severity: Major
                Found in modules/mu/providers/google/role.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                    "arn:"+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+":iam::aws:policy/"+policy
                  Severity: Major
                  Found in modules/mu/providers/aws/role.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if type['level'] == node['glusterfs']['server']['raid_level'] and type['spare'] == node['glusterfs']['server']['raid_spare_vol'] and node['glusterfs']['server']['devices'].size >= type['min_devcies']
                                  raid_no_spare(node['glusterfs']['server']['raid_dev'], node['glusterfs']['server']['raid_level'], node['glusterfs']['server']['devices'].size, node['glusterfs']['server']['devices'].join(" "))
                                end
                    Severity: Major
                    Found in cookbooks/mu-glusterfs/recipes/server.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                    if name.nil?
                      #                Aws.config = {
                      #                  access_key_id: data['access_key'],
                      #                  secret_access_key: data['access_secret'],
                      #                  region: cred_cfg['region']
                      Severity: Major
                      Found in modules/mu/providers/aws.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if args[:types].include?(shortclass) and
                                                   !(entity_type == "serviceAccount" and
                                                     MU::Cloud::Google::User.cannedServiceAcctName?(entity))
                                                  MU.log "Role #{@cloud_id}: Skipping #{shortclass} binding for #{entity}; we are adopting that type and will set bindings from that resource", MU::DEBUG
                                                  next
                        Severity: Major
                        Found in modules/mu/providers/google/role.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              raise e if !e.message.match(/(?:forbidden|notFound): /)
                          Severity: Major
                          Found in modules/mu/providers/google/role.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                public = dnsrec["target_type"] == "private" ? false : true
                            Severity: Major
                            Found in modules/mu/providers/aws/dnszone.rb - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                    if tg_name = @deploy.getResourceName(tg_cfg["name"], max_length: 32, disallowed_chars: /[^A-Za-z0-9-]/)
                                                      tg_name = tg_cfg['name']
                                                      break
                                                    end
                              Severity: Major
                              Found in modules/mu/providers/aws/loadbalancer.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                      id.sub!(/:([^:]+)$/, ":"+'\1'+target["path"]) if target["path"]
                                Severity: Major
                                Found in modules/mu/providers/aws/role.rb - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                  if policy["step_adjustments"].nil? || policy["step_adjustments"].empty?
                                                    MU.log "You must specify 'step_adjustments' 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

                                                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

                                                        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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language