saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    for _, cur_struct_val in six.iteritems(cur_struct):
                        found |= _compare(cmp_value, cur_struct_val)
                    return found
Severity: Major
Found in salt/beacons/napalm_beacon.py - About 45 mins to fix

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

    def validate(config):
        '''
        Validate the beacon configuration
        '''
        # Configuration for adb beacon should be a dictionary with states array
    Severity: Minor
    Found in salt/beacons/salt_proxy.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 'recurse' in _config['files'][path]:
                            if not isinstance(_config['files'][path]['recurse'], bool):
                                return False, ('Configuration for inotify beacon '
                                               'recurse must be boolean.')
    
    
    Severity: Major
    Found in salt/beacons/inotify.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if trans == 'zeromq' and not zmq:
                                      continue
                                  self.opts['transport'] = trans
      Severity: Major
      Found in salt/minion.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if close_str in self.beacons:
                                    log.info('Closing beacon %s. State run in progress.', mod)
                                    self.beacons[close_str](b_config[mod])
                                else:
                                    log.info('Skipping beacon %s. State run in progress.', mod)
        Severity: Major
        Found in salt/beacons/__init__.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if 'auto_add' in _config['files'][path]:
                                  if not isinstance(_config['files'][path]['auto_add'], bool):
                                      return False, ('Configuration for inotify beacon '
                                                     'auto_add must be boolean.')
          
          
          Severity: Major
          Found in salt/beacons/inotify.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if isinstance(exclude, dict):
                                    excl.append(list(exclude)[0])
                                else:
                                    excl.append(exclude)
                            excl = pyinotify.ExcludeFilter(excl)
            Severity: Major
            Found in salt/beacons/inotify.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if not any(j in ['mask',
                                                   'recurse',
                                                   'auto_add'] for j in _config['files'][path]):
                                      return False, ('Configuration for inotify beacon must '
                                                     'contain mask, recurse or auto_add items.')
              Severity: Major
              Found in salt/beacons/inotify.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if labels_key:
                                            # at the same depth
                                            labels = ret.get(labels_key)  # if any
                                        out.extend(self.display_rows(rows, labels, indent))
                Severity: Major
                Found in salt/output/table_out.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for item in ret['data']:
                                          comment = '{0} {1}'.format(comment, item)
                                  elif isinstance(ret['data'], dict):
                  Severity: Major
                  Found in salt/output/highstate.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if ind % 2 != 0:
                                            event['args'].append(field)
                                    event['user'] = __context__[pkey][pid]['user']
                    Severity: Major
                    Found in salt/beacons/sh.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if isinstance(_user, dict) and 'time_range' in _user:
                                              if _check_time_range(_user['time_range'], now):
                                                  ret.append(event)
                                          else:
                                              if defaults and 'time_range' in defaults:
                      Severity: Major
                      Found in salt/beacons/btmp.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if cmp_key not in cur_struct:
                                                return False
                                            return _compare(cmp_value, cur_struct[cmp_key])
                        Severity: Major
                        Found in salt/beacons/napalm_beacon.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if 'servers' not in _config['backends'][backend]:
                                                  return False, ('Backends for haproxy beacon '
                                                                 'require servers.')
                                              else:
                                                  _servers = _config['backends'][backend]['servers']
                          Severity: Major
                          Found in salt/beacons/haproxy.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if _check_time_range(defaults['time_range'], now):
                                                    ret.append(event)
                                            else:
                            Severity: Major
                            Found in salt/beacons/wtmp.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if _check_time_range(defaults['time_range'], now):
                                                      ret.append(event)
                                              else:
                              Severity: Major
                              Found in salt/beacons/btmp.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/minion.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if isinstance(item, dict) and '__kwarg__' in item:
                                                          clikwargs = item.copy()
                                  
                                  
                                  Severity: Major
                                  Found in salt/output/highstate.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if device not in last_state:
                                                                last_state[device] = {}
                                    
                                    
                                    Severity: Major
                                    Found in salt/beacons/adb.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          if isinstance(event[field], bytes):
                                                              event[field] = salt.utils.stringutils.to_unicode(event[field])
                                                          event[field] = event[field].strip('\x00')
                                      Severity: Major
                                      Found in salt/beacons/btmp.py - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language