saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def vbd_list(name=None, call=None):
    '''
    Get a list of VBDs on a VM

    **requires**: the name of the vm with the vbd definition
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

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

def _list_linodes(full=False):
    '''
    Helper function to format and parse linode data
    '''
    nodes = _query('linode', 'list')['DATA']
Severity: Minor
Found in salt/cloud/clouds/linode.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_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

                            if vmcfg['cpu_cap'] != '':
                                ret[vm]['resources']['cpu'] = "{0:.2f}".format(int(vmcfg['cpu_cap'])/100)
                    else:
    Severity: Major
    Found in salt/runners/smartos_vmadm.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if ipnet:
                              inet_ips = [
                                  six.text_type(ip) for ip in ips if _ipnet_belongs(ip)
                              ]  # filter and get only IP include ipnet
                              if inet_ips:  # if any
      Severity: Major
      Found in salt/runners/net.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if base:
                                above.insert(0, base)
                            sroot = os.path.dirname(sroot)
        Severity: Major
        Found in salt/wheel/file_roots.py - About 45 mins to fix

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

          def top(**kwargs):
              '''
              Connect to a mongo database and read per-node tops data.
          
              Parameters:
          Severity: Minor
          Found in salt/tops/mongo.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

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

          def flush(bank, key=None, cachedir=None):
              '''
              Remove the key from the cache bank with all the key content.
              '''
              if cachedir is None:
          Severity: Minor
          Found in salt/cache/localfs.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 kwargs and not _compare_match(kwargs, neighbor):
                                  # requested filtering by neighbors stats
                                  # but this one does not correspond
                                  continue
                              if neighbor_ip and neighbor_ip != neighbor.get('remote_address'):
          Severity: Major
          Found in salt/runners/bgp.py - About 45 mins to fix

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

            def find(path, saltenv='base'):
                '''
                Return a dict of the files located with the given path and environment
                '''
                # Return a list of paths + text or bin
            Severity: Minor
            Found in salt/wheel/file_roots.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 not((ptl in rsn.lower()) or (ptl in rsd.lower()) or
                                       (ptl in rpd.lower()) or (ptl in rci.lower())):
                                    # nothing matched, let's move on
                                    continue
                            if chassis:
            Severity: Major
            Found in salt/runners/net.py - About 45 mins to fix

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

              def delete_device(name, safety_on=True):
                  '''
                  Deletes a device from Vistara based on DNS name or partial name. By default,
                  delete_device will only perform the delete if a single host is returned. Set
                  safety_on=False to delete all matches (up to default API search page size)
              Severity: Minor
              Found in salt/runners/vistara.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 base:
                                      above.insert(0, base)
                                  sroot = os.path.dirname(sroot)
              Severity: Major
              Found in salt/wheel/pillar_roots.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if host in ret:
                                        ret[host].append(name)
                                    else:
                                        ret[host] = [name]
                    return ret
                Severity: Major
                Found in salt/runners/lxc.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for pkgname, versions in six.iteritems(config):
                                          log.debug(
                                              'Compiling winrepo data for package \'%s\'',
                                              pkgname
                                          )
                  Severity: Major
                  Found in salt/runners/winrepo.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if display:
                                            interf_entry['ips'] = '\n'.join(interf_entry['ips'])
                                        if ipnet:
                    Severity: Major
                    Found in salt/runners/net.py - About 45 mins to fix

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

                      def request(
                              minion_id,
                              dns_name=None,
                              zone='default',
                              request_id=None,
                      Severity: Minor
                      Found in salt/runners/venafiapi.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

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

                      def find(path, saltenv='base'):
                          '''
                          Return a dict of the files located with the given path and environment
                          '''
                          # Return a list of paths + text or bin
                      Severity: Minor
                      Found in salt/wheel/pillar_roots.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

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

                      def delete_host(zone, name, keyname, keyfile, nameserver, timeout, port=53,
                                      keyalgorithm='hmac-md5'):
                          '''
                          Delete both forward (A) and reverse (PTR) records for a host only if the
                          forward (A) record exists.
                      Severity: Minor
                      Found in salt/runners/ddns.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 (napalm_helpers.convert(napalm_helpers.mac, rci) !=
                                             napalm_helpers.convert(napalm_helpers.mac, chassis)):
                                              continue
                                      rows.append({
                      Severity: Major
                      Found in salt/runners/net.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language