saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if isinstance(host, vim.HostSystem):
                        ret[datacenter['name']].append(host.name)
        if datacenter_name and datacenter_name == datacenter['name']:
Severity: Major
Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if hasattr(device, 'connectable') and device.connectable:
                            device_full_info[device.deviceInfo.label]['startConnected'] = device.connectable.startConnected
                            device_full_info[device.deviceInfo.label]['allowGuestControl'] = device.connectable.allowGuestControl
                            device_full_info[device.deviceInfo.label]['connected'] = device.connectable.connected
                            device_full_info[device.deviceInfo.label]['status'] = device.connectable.status
    Severity: Major
    Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if hba.model in ret[host['name']]:
                              ret[host['name']][hba.model][hba.device] = hba_spec
                          else:
                              ret[host['name']][hba.model] = {hba.device: hba_spec}
                  else:
      Severity: Major
      Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

        Function create_service has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def create_service(kwargs=None, conn=None, call=None):
            '''
            .. versionadded:: 2015.8.0
        
            Create a new hosted service
        Severity: Minor
        Found in salt/cloud/clouds/msazure.py - 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 hasattr(device, 'controllerKey') and device.controllerKey:
                                device_full_info[device.deviceInfo.label]['controllerKey'] = device.controllerKey
        
        
        Severity: Major
        Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if device.deviceInfo.label in list(devices['network'].keys()):
                                  network_name = devices['network'][device.deviceInfo.label]['name']
                                  adapter_type = devices['network'][device.deviceInfo.label]['adapter_type'] if 'adapter_type' in devices['network'][device.deviceInfo.label] else ''
                                  switch_type = devices['network'][device.deviceInfo.label]['switch_type'] if 'switch_type' in devices['network'][device.deviceInfo.label] else ''
                                  network_spec = _edit_existing_network_adapter(device, network_name, adapter_type, switch_type, container_ref)
          Severity: Major
          Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if 'gw' in _stringlist_to_dictionary(vm_[setting]):
                                    new_setting.update(_stringlist_to_dictionary(
                                        'ip={0}/24,gw={1}'.format(
                                            vm_['ip_address'], _stringlist_to_dictionary(vm_[setting])['gw'])))
                                else:
            Severity: Major
            Found in salt/cloud/clouds/proxmox.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if 'name' in node:
                                      node['location'] = location
                                      ret[node['name']] = reformat_node(item=node, full=full)
                          else:
              Severity: Major
              Found in salt/cloud/clouds/joyent.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if sleep_time > 0.0:
                                        log.info('delaying %d seconds for boot', sleep_time)
                                        time.sleep(sleep_time)
                        log.info('Provisioning existing machine %s', vm_['name'])
                Severity: Major
                Found in salt/cloud/clouds/saltify.py - About 45 mins to fix

                  Function destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def destroy(name, call=None):
                      '''
                      Destroy a node.
                  
                      CLI Example:
                  Severity: Minor
                  Found in salt/cloud/clouds/proxmox.py - 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 setting_storage != vm_disk_storage:
                                          postParams = {}
                                          postParams['disk'] = setting
                                          postParams['storage'] = setting_storage
                                          postParams['delete'] = 1
                  Severity: Major
                  Found in salt/cloud/clouds/proxmox.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if setting_storage != vm_disk_storage:
                                            postParams = {}
                                            postParams['disk'] = setting
                                            postParams['storage'] = setting_storage
                                            postParams['delete'] = 1
                    Severity: Major
                    Found in salt/cloud/clouds/proxmox.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if 'iso' not in vdi_record['name_label']:
                                              session.xenapi.VDI.destroy(vbd_record['VDI'])
                                              ret['vdi-{}'.format(x)] = vdi_record['name_label']
                                      x += 1
                      Severity: Major
                      Found in salt/cloud/clouds/xen.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if setting_size != vm_disk_size:
                                                postParams = {}
                                                postParams['disk'] = setting
                                                postParams['size'] = setting_size
                                                query('put', 'nodes/{0}/qemu/{1}/resize'.format(
                        Severity: Major
                        Found in salt/cloud/clouds/proxmox.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  for if_addr in interface['ip-addresses']:
                                                      ip_addr = if_addr['ip-address']
                                                      # Ensure interface has a valid IPv4 address
                                                      if if_addr['ip-address-type'] == 'ipv4' and ip_addr is not None:
                                                          return six.text_type(ip_addr)
                          Severity: Major
                          Found in salt/cloud/clouds/proxmox.py - About 45 mins to fix

                            Function set_vm_ip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def set_vm_ip(name=None,
                                          ipv4_cidr=None,
                                          ipv4_gw=None,
                                          session=None,
                                          call=None):
                            Severity: Minor
                            Found in salt/cloud/clouds/xen.py - 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 isinstance(value[i - 1], dict):
                                                    for sk, sv in value[i - 1].items():
                                                        if isinstance(sv, dict) or isinstance(sv, list):
                                                            sv = salt.utils.json.dumps(sv, separators=(',', ':'))
                                                        real_parameters['{0}.{1}.{2}'.format(key, i, sk)] = sv
                            Severity: Major
                            Found in salt/cloud/clouds/qingcloud.py - About 45 mins to fix

                              Function _wait_for_ip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def _wait_for_ip(name, session):
                                  '''
                                  Wait for IP  to be available during create()
                                  '''
                                  start_time = datetime.now()
                              Severity: Minor
                              Found in salt/cloud/clouds/xen.py - 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 ip_.is_private:
                                                      private_ips.append(adrs)
                                                  else:
                                                      public_ips.append(adrs)
                              
                              
                              Severity: Major
                              Found in salt/cloud/clouds/saltify.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if salt.utils.cloud.is_public_ip(ip_address):
                                                        ret[role]['public_ips'].append(ip_address)
                                                    else:
                                                        ret[role]['private_ips'].append(ip_address)
                                                ret[role]['size'] = role_instances[role]['instance_size']
                                Severity: Major
                                Found in salt/cloud/clouds/msazure.py - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language