cloudamatic/mu

View on GitHub

Showing 255 of 2,705 total issues

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

        def create
          @cfm_name, @cfm_template = MU::Cloud::CloudFormation.cloudFormationBase(self.class.cfg_name, self, tags: @config['tags'], scrub_mu_isms: @config['scrub_mu_isms']) if @cfm_template.nil?
          @cfm_launch_name, launch_template = MU::Cloud::CloudFormation.cloudFormationBase("launch_config", self, scrub_mu_isms: @config['scrub_mu_isms'])
          MU::Cloud::CloudFormation.setCloudFormationProp(@cfm_template[@cfm_name], "LaunchConfigurationName", { "Ref" => @cfm_launch_name } )
          MU::Cloud::CloudFormation.setCloudFormationProp(@cfm_template[@cfm_name], "DependsOn", @cfm_launch_name)
Severity: Minor
Found in modules/mu/providers/cloudformation/server_pool.rb - About 1 hr 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

Method schema has 152 lines of code (exceeds 150 allowed). Consider refactoring.
Open

        def self.schema(_config)
          toplevel_required = []

          schema = {
            "disabled" => {
Severity: Major
Found in modules/mu/providers/aws/cdn.rb - About 1 hr to fix

    Method create_update has 151 lines of code (exceeds 150 allowed). Consider refactoring.
    Open

            def create_update
              ipcfg = MU::Cloud::Azure.network(:NetworkInterfaceIPConfiguration).new
              ipcfg.name = @mu_name
              ipcfg.private_ipallocation_method = MU::Cloud::Azure.network(:IPAllocationMethod)::Dynamic
    
    
    Severity: Major
    Found in modules/mu/providers/azure/server.rb - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                          child_params = Hash.new if child_params.nil?
      Severity: Major
      Found in modules/mu/providers/cloudformation.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      break if elt == other_elt # if they're identical, we're done
        Severity: Major
        Found in modules/mu.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 retval.error
                                    raise MuError, retval.error.message
                                  end
            Severity: Major
            Found in modules/mu/providers/google.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if retries < max_retries
                                        sleep 30
                                        retries += 1
                                        puts retries
                                      else
              Severity: Major
              Found in modules/mu/providers/google/folder.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                      if e.message.match(/failedPrecondition/) and retries < max_retries
                                        sleep 30
                                        retries += 1
                                        retry
                                      else
                Severity: Major
                Found in modules/mu/providers/google/folder.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      subnet.private? ? priv_nets << { "Ref" => "#{subnet.cfm_name}" } : pub_nets << { "Ref" => "#{subnet.cfm_name}" }
                  Severity: Major
                  Found in modules/mu/providers/cloudformation.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if e.message.match(/Cannot delete an inactive project/)
                                          # this is fine
                                        else
                                          MU.log "Got #{e.message} trying to delete project #{p.project_id} (#{p.name})", MU::ERR
                                          next
                    Severity: Major
                    Found in modules/mu/providers/google/habitat.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          raise MuError, "Failed to delete filesystem #{pool.name}: #{pool.file_system_id}, still in use." if attempts >= 6
                      Severity: Major
                      Found in modules/mu/providers/aws/storage_pool.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        if !resp or !resp.attached_policies.map { |a_p| a_p.policy_name }.include?(p.policy_name)
                                          MU.log "Attaching policy #{p.policy_name} to group #{entityname}", MU::NOTICE
                                          MU::Cloud::AWS.iam(credentials: @credentials).attach_group_policy(
                                            policy_arn: p.arn,
                                            group_name: entityname
                        Severity: Major
                        Found in modules/mu/providers/aws/role.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                if id.match(/:log-group:/)
                                                  stream_id = id.sub(/:([^:]+)$/, ":log-stream:*")
                          #                        "arn:aws:logs:us-east-2:accountID:log-group:log_group_name:log-stream:CloudTrail_log_stream_name_prefix*"
                                                  statement["Resource"] << stream_id
                                                elsif id.match(/:s3:/)
                          Severity: Major
                          Found in modules/mu/providers/aws/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

                                      semanage_pkg = if node['platform_version'].to_i < 6
                                        "policycoreutils"
                                      elsif node['platform_version'].to_i < 8
                                        "policycoreutils-python"
                                      else
                              Severity: Major
                              Found in cookbooks/mu-tools/recipes/rsyslog.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            raise MuError, "No valid credentials available! Either grant admin privileges to machine service account, or manually add a different one with mu-configure" if found.nil?
                                Severity: Major
                                Found in modules/mu/providers/google.rb - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                    if subpaths.size > 0
                                                      p_arn = "arn:"+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+":iam::aws:policy/#{subpaths.shift}/"+policy
                                                      retry
                                                    end
                                  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 new_args.size == 1 and new_args.first.is_a?(Hash)
                                                              new_args[0][page_markers[paginator]] = new_page
                                                            else
                                                              MU.log "I don't know how to insert a #{paginator} into these arguments for #{method_sym}", MU::WARN, details: new_args
                                                            end
                                      Severity: Major
                                      Found in modules/mu/providers/aws.rb - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language