saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    for line in _fp:
                        line = salt.utils.stringutils.to_unicode(line)
                        line = line.partition('#')[0].strip()
                        if line:
                            if line.split()[-1] == '{':
Severity: Major
Found in salt/modules/freebsdjail.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if args[index].startswith('-') or (args[index] == '!' and
                                                           not swap):
                            args.insert(index, '')
                        else:
                            while (index + 1 < len(args) and
    Severity: Major
    Found in salt/modules/iptables.py - About 45 mins to fix

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

      def create_site(name, sourcepath, apppool='', hostheader='',
                      ipaddress='*', port=80, protocol='http', preload=''):
          '''
          Create a basic website in IIS.
      
      
      Severity: Minor
      Found in salt/modules/win_iis.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 line:
                              continue
                          if line.startswith('#'):
      Severity: Major
      Found in salt/modules/freebsdjail.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if node.getAttribute('type') == 'error':
                                    _error_msg.append(node.childNodes[0].nodeValue)
                        elif self.__call_result['stderr'].strip():
        Severity: Major
        Found in salt/modules/zypperpkg.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if oem_release:
                                  p_nfo['release'] = oem_release
                  ret.append(p_nfo)
          Severity: Major
          Found in salt/modules/zypperpkg.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if line.startswith('#'):
                                    continue
                                try:
            Severity: Major
            Found in salt/modules/freebsdjail.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if not retcode == 0:
                                      break
                              # provided list is '': users previously deleted from group
                              else:
              Severity: Major
              Found in salt/modules/groupadd.py - About 45 mins to fix

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

                def convert(device, permanent=False, keeplf=False):
                    '''
                    Convert ext2/3/4 to BTRFS. Device should be mounted.
                
                    Filesystem can be converted temporarily so the further processing and rollback is possible,
                Severity: Minor
                Found in salt/modules/btrfs.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 subvolume_delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def subvolume_delete(name=None, names=None, commit=None):
                    '''
                    Delete the subvolume(s) from the filesystem
                
                    The user can remove one single subvolume (name) or multiple of
                Severity: Minor
                Found in salt/modules/btrfs.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 _read_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _read_config(conf_file=None):
                    '''
                    Reads the config file using configparser
                    '''
                    if conf_file is None:
                Severity: Minor
                Found in salt/modules/supervisord.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 tmp:
                                        job_tag = tmp.groups()[0]
                
                        # filter on tags
                        if not tag:
                Severity: Major
                Found in salt/modules/at_solaris.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for g_attr, g_attr_map in six.iteritems(g_attrs):
                                          g_val = getattr(grant, g_attr)
                                          if not g_val:
                                              continue
                                          _grant[g_attr_map] = g_val
                  Severity: Major
                  Found in salt/modules/boto_secgroup.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if line.find('Type=oneshot') > 0:
                                            # scripts that does a single job and then exit
                                            is_oneshot = True
                                        continue
                    Severity: Major
                    Found in salt/modules/restartcheck.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          for l in f:
                                              l = salt.utils.data.decode(l, encoding='utf-8').rstrip()
                                              l = re.sub(r'(.*)#(.*)', r'\1', l)
                                              if '__virtualname__ =' in l and not virtualname:
                                                  virtualname = l.split()[2].strip("'").strip('"')
                      Severity: Major
                      Found in salt/modules/baredoc.py - About 45 mins to fix

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

                        def vm_netstats(vm_=None):
                            '''
                            Return combined network counters used by the vms on this hyper in a
                            list of dicts:
                        
                        
                        Severity: Minor
                        Found in salt/modules/xapi_virt.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 _connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def _connect(user=None, password=None, host=None, port=None, database='admin', authdb=None):
                            '''
                            Returns a tuple of (user, host, port) with config, pillar, or default
                            values assigned to missing values.
                            '''
                        Severity: Minor
                        Found in salt/modules/mongodb.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 at has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def at(*args, **kwargs):  # pylint: disable=C0103
                            '''
                            Add a job to the queue.
                        
                            The 'timespec' follows the format documented in the
                        Severity: Minor
                        Found in salt/modules/at_solaris.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 vm_diskstats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def vm_diskstats(vm_=None):
                            '''
                            Return disk usage counters used by the vms on this hyper in a
                            list of dicts:
                        
                        
                        Severity: Minor
                        Found in salt/modules/xapi_virt.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 add_host has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def add_host(mac, name=None, ip=None, ddns=False, group=None,
                                supersede_host=False):
                            '''
                            Add a host object for the given mac.
                        
                        
                        Severity: Minor
                        Found in salt/modules/omapi.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

                        Severity
                        Category
                        Status
                        Source
                        Language