saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        for line in ifile:
                            # Need to pull out the version and codename
                            # in the case of custom content in /etc/centos-release
                            find_release = re.compile(r'\d+\.\d+')
                            find_codename = re.compile(r'(?<=\()(.*?)(?=\))')
Severity: Major
Found in salt/grains/core.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if res and len(res.groups()) >= 1:
                            grains[dest] = res.group(1).strip().replace("'", '')
    
    
    Severity: Major
    Found in salt/grains/core.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if ':' in driver:
                              # Weird, but...
                              alias, driver = driver.split(':')
      
      
      Severity: Major
      Found in salt/config/__init__.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if 'extends' not in details:
                                log.error(
                                    'Please check your cloud providers configuration. '
                                    'There\'s no \'driver\' nor \'extends\' definition '
                                    'referenced.'
        Severity: Major
        Found in salt/config/__init__.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for key, val in six.iteritems(string_kwarg):
                                  invalid_kwargs.append('{0}={1}'.format(key, val))
                      else:
          Severity: Major
          Found in salt/minion.py - About 45 mins to fix

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

            def _handle_signals(client, signum, sigframe):
                try:
                    # This raises AttributeError on Python 3.4 and 3.5 if there is no current exception.
                    # Ref: https://bugs.python.org/issue23003
                    trace = traceback.format_exc()
            Severity: Minor
            Found in salt/scripts.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 _call_syndic has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def _call_syndic(self, func, args=(), kwargs=None, master_id=None):
                    '''
                    Wrapper to call a given func on a syndic, best effort to get the one you asked for
                    '''
                    if kwargs is None:
            Severity: Minor
            Found in salt/minion.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 pkginrepo.match(line):
                                    grains['pkgin_repositories'].append(line)
            
            
            Severity: Major
            Found in salt/grains/smartos.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if vz_match and int(vz_match.groups()[0]) != 0:
                                      grains['virtual'] = 'openvzve'
                                  elif vz_match and int(vz_match.groups()[0]) == 0:
                                      grains['virtual'] = 'openvzhn'
                      if isdir('/proc/sys/xen') or \
              Severity: Major
              Found in salt/grains/core.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if osminorrelease:
                                            osrelease.append(osminorrelease)
                                        grains['osrelease'] = ".".join(osrelease)
                Severity: Major
                Found in salt/grains/core.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if match_pkgsrcpath:
                                          grains['pkgsrcpath'] = match_pkgsrcpath.group(1)
                                          match_pkgsrcversion = pkgsrcversion.match(match_pkgsrcpath.group(1))
                                          if match_pkgsrcversion:
                                              grains['pkgsrcversion'] = match_pkgsrcversion.group(1)
                  Severity: Major
                  Found in salt/grains/smartos.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            for line in fp_:
                                                try:
                                                    key, val = line.rstrip('\n').split('=')
                                                except ValueError:
                                                    continue
                    Severity: Major
                    Found in salt/grains/core.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if driver in providers.get(extends):
                                              details['extends'] = '{0}:{1}'.format(extends, driver)
                                          elif '-only-extendable-' in providers.get(extends):
                                              details['extends'] = '{0}:{1}'.format(
                                                  extends, '-only-extendable-{0}'.format(ext_count)
                      Severity: Major
                      Found in salt/config/__init__.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if opts['master'] in opts['local_masters']:
                                                    # create new list of master with the possibly failed
                                                    # one moved to the end
                                                    failed_master = opts['master']
                                                    opts['master'] = [x for x in opts['local_masters'] if opts['master'] != x]
                        Severity: Major
                        Found in salt/minion.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  for line in fhr:
                                                      if 'enterprise' in line.lower():
                                                          grains['lsb_distrib_id'] = 'SLES'
                                                          grains['lsb_distrib_codename'] = re.sub(r'\(.+\)', '', line).strip()
                                                      elif 'version' in line.lower():
                          Severity: Major
                          Found in salt/grains/core.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if len(synoinfo) != 3:
                                                        log.warning(
                                                            'Unable to determine Synology version info. '
                                                            'Please report this, as it is likely a bug.'
                                                        )
                            Severity: Major
                            Found in salt/grains/core.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if 'Features' in line:
                                                      start = line.find('<')
                                                      end = line.find('>')
                                                      if start > 0 and end > 0:
                                                          flag = line[start + 1:end].split(',')
                              Severity: Major
                              Found in salt/grains/core.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if os_release['ID'] == 'debian':
                                                            codename_match = re.search(r'\((\w+)\)$', codename)
                                                            if codename_match:
                                                                codename = codename_match.group(1)
                                                        grains['lsb_distrib_codename'] = codename
                                Severity: Major
                                Found in salt/grains/core.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if not iret:
                                                              iret = []
                                                          iret.append(single)
                                  Severity: Major
                                  Found in salt/metaproxy/proxy.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if 'driver' not in detail:
                                                            raise salt.exceptions.SaltCloudConfigError(
                                                                'The cloud provider alias \'{0}\' has an entry '
                                                                'missing the required setting of \'driver\'.'.format(
                                                                    alias
                                    Severity: Major
                                    Found in salt/config/__init__.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language