cloudamatic/mu

View on GitHub

Showing 255 of 2,705 total issues

File config.rb has 1009 lines of code (exceeds 1000 allowed). Consider refactoring.
Open

require 'rubygems'
require 'json'
require 'erb'
require 'pp'
require 'json-schema'
Severity: Major
Found in modules/mu/config.rb - About 2 hrs to fix

    Method manageUser has 178 lines of code (exceeds 150 allowed). Consider refactoring.
    Open

          def self.manageUser(user, name: nil, password: nil, email: nil, admin: false, mu_acct: true, unlock: false, ou: $MU_CFG["ldap"]["user_ou"], enable: false, disable: false, change_uid: -1)
            cur_users = listUsers
    
            first = last = nil
            if !name.nil?
    Severity: Major
    Found in modules/mu/master/ldap.rb - About 2 hrs to fix

      Method groom has 177 lines of code (exceeds 150 allowed). Consider refactoring.
      Open

              def groom
                labelCluster 
      
                me = cloud_desc
      
      
      Severity: Major
      Found in modules/mu/providers/google/container_cluster.rb - About 2 hrs to fix

        Method generateBaskets has 174 lines of code (exceeds 150 allowed). Consider refactoring.
        Open

            def generateBaskets(prefix: "")
              groupings = {
                "" =>  MU::Cloud.resource_types.values.map { |v| v[:cfg_plural] }
              }
        
        
        Severity: Major
        Found in modules/mu/adoption.rb - About 1 hr to fix

          Method createUpdateLaunchConfig has 173 lines of code (exceeds 150 allowed). Consider refactoring.
          Open

                  def createUpdateLaunchConfig
                    return if !@config['basis'] or !@config['basis']["launch_config"]
          
                    instance_secret = Password.random(50)
                    @deploy.saveNodeSecret("default", instance_secret, "instance_secret")
          Severity: Major
          Found in modules/mu/providers/aws/server_pool.rb - About 1 hr to fix

            Method validate has 173 lines of code (exceeds 150 allowed). Consider refactoring.
            Open

                  def self.validate(db, configurator)
                    ok = true
                    read_replicas = []
                    cluster_nodes = []
            
            
            Severity: Major
            Found in modules/mu/config/database.rb - About 1 hr to fix

              Method cleanup has a Cognitive Complexity of 85 (exceeds 75 allowed). Consider refactoring.
              Open

                      def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
                        MU.log "AWS::StoragePool.cleanup: need to support flags['known']", MU::DEBUG, details: flags
              
                        supported_regions = %w{us-west-2 us-east-1 eu-west-1}
                        if supported_regions.include?(region)
              Severity: Minor
              Found in modules/mu/providers/aws/storage_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 create has 171 lines of code (exceeds 150 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: Major
              Found in modules/mu/providers/cloudformation/server_pool.rb - About 1 hr to fix

                Method create has 169 lines of code (exceeds 150 allowed). Consider refactoring.
                Open

                        def create
                          flag="SUCCESS"
                          MU.setVar("curRegion", @region) if !@region.nil?
                          region = @region
                          server=@config["name"]
                Severity: Major
                Found in modules/mu/providers/aws/collection.rb - About 1 hr to fix

                  Method credConfig has a Cognitive Complexity of 84 (exceeds 75 allowed). Consider refactoring.
                  Open

                        def self.credConfig(name = nil, name_only: false)
                          # If there's nothing in mu.yaml (which is wrong), but we're running
                          # on a machine hosted in AWS, *and* that machine has an IAM profile,
                          # fake it with those credentials and hope for the best.
                          if !$MU_CFG['aws'] or !$MU_CFG['aws'].is_a?(Hash) or $MU_CFG['aws'].size == 0
                  Severity: Minor
                  Found in modules/mu/providers/aws.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 search_my_deploys has a Cognitive Complexity of 84 (exceeds 75 allowed). Consider refactoring.
                  Open

                      def self.search_my_deploys(type, deploy_id: nil, name: nil, mu_name: nil, cloud_id: nil, credentials: nil)
                        kittens = {}
                        _shortclass, _cfg_name, type, _classname, attrs = MU::Cloud.getResourceNames(type, true)
                  
                        # Check our in-memory cache of live deploys before resorting to
                  Severity: Minor
                  Found in modules/mu/mommacat/search.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 run has 168 lines of code (exceeds 150 allowed). Consider refactoring.
                  Open

                        def run(purpose: "Chef run", update_runlist: true, max_retries: 5, output: true, override_runlist: nil, reboot_first_fail: false, timeout: 1800)
                          self.class.loadChefLib
                          if update_runlist and !@config['run_list'].nil?
                            knifeAddToRunList(multiple: @config['run_list'])
                          end
                  Severity: Major
                  Found in modules/mu/groomers/chef.rb - About 1 hr to fix

                    Method validateConfig has 167 lines of code (exceeds 150 allowed). Consider refactoring.
                    Open

                            def self.validateConfig(vpc, configurator)
                              ok = true
                    
                              if vpc["enable_traffic_logging"]
                                logdesc = {
                    Severity: Major
                    Found in modules/mu/providers/aws/vpc.rb - About 1 hr to fix

                      Method cleanup has a Cognitive Complexity of 83 (exceeds 75 allowed). Consider refactoring.
                      Open

                              def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, credentials: nil, flags: {})
                                customer = MU::Cloud::Google.customerID(credentials)
                                my_org = MU::Cloud::Google.getOrg(credentials)
                      
                                filter = %Q{(labels.mu-id = "#{MU.deploy_id.downcase}")}
                      Severity: Minor
                      Found in modules/mu/providers/google/role.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 resolveReferences has a Cognitive Complexity of 83 (exceeds 75 allowed). Consider refactoring.
                      Open

                          def resolveReferences(cfg, deploy, parent)
                            mask_deploy_id = false
                      
                            check_deploy_id = Proc.new { |cfgblob|
                              (deploy and
                      Severity: Minor
                      Found in modules/mu/adoption.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 validateConfig has 157 lines of code (exceeds 150 allowed). Consider refactoring.
                      Open

                              def self.validateConfig(pool, configurator)
                                ok = true
                      
                                if pool["termination_policy"]
                                  valid_policies = MU::Cloud::AWS.autoscale(region: pool['region']).describe_termination_policy_types.termination_policy_types
                      Severity: Major
                      Found in modules/mu/providers/aws/server_pool.rb - About 1 hr to fix

                        Method get_properties has 156 lines of code (exceeds 150 allowed). Consider refactoring.
                        Open

                                def get_properties
                                  params = {
                                    default_root_object: @config['default_object'],
                                    caller_reference: @mu_name, # eh, probably should be random
                                    origins: {
                        Severity: Major
                        Found in modules/mu/providers/aws/cdn.rb - About 1 hr to fix

                          Method create has 155 lines of code (exceeds 150 allowed). Consider refactoring.
                          Open

                                  def create
                                    MU.log "Creating VPC #{@mu_name}", details: @config
                                    resp = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).create_vpc(cidr_block: @config['ip_block']).vpc
                                    @cloud_id = resp.vpc_id
                                    @config['vpc_id'] = @cloud_id
                          Severity: Major
                          Found in modules/mu/providers/aws/vpc.rb - About 1 hr to fix

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

                                    def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
                                      if (deploy_id.nil? or deploy_id.empty?) and (!flags or !flags["vpc_id"])
                                        raise MuError, "Can't touch ELBs without MU-ID or vpc_id flag"
                                      end
                            
                            
                            Severity: Minor
                            Found in modules/mu/providers/aws/loadbalancer.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 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

                            Severity
                            Category
                            Status
                            Source
                            Language