saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if len(_config['averages'][item]) != 2:
                        return False, ('Configuration for load beacon: '
                                       '1m, 5m and 15m items must be '
                                       'a list of two items.')

Severity: Major
Found in salt/beacons/load.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/wtmp.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if interface_config[attr] and \
                             'onvalue' in interface_config[attr]:
                              config_value = interface_config[attr]['onvalue']
                          new_value = ast.literal_eval(_diff_stats_dict[attr])
      Severity: Major
      Found in salt/beacons/network_settings.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if _config['services'][name][key] == cur[key]:
                                n_flag += 1
                    if n_flag == len(_config['services'][name]):
        Severity: Major
        Found in salt/beacons/journald.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if wm.watches[wd].mask != mask:
                                  update = True
                              if wm.watches[wd].auto_add != auto_add:
          Severity: Major
          Found in salt/beacons/inotify.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if not pub_channel.auth.authenticated:
                                            continue
                                        del self.opts['detect_mode']
            Severity: Major
            Found in salt/minion.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if not config_value or config_value == new_value:
                                      _send_event = True
                                      _ret_diff[attr] = new_value
              
              
              Severity: Major
              Found in salt/beacons/network_settings.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if isinstance(exclude, dict):
                                        _exclude = next(iter(exclude))
                                        if exclude[_exclude].get('regex', False):
                                            try:
                                                if re.search(_exclude, event.pathname):
                Severity: Major
                Found in salt/beacons/inotify.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if policy == 'any' and bool(cnt) or cnt == len(mapping):
                                              if self.opts['discovery'].get('multimaster'):
                                                  discovered.append(proto_data['master'])
                                              else:
                                                  self.opts['master'] = proto_data['master']
                  Severity: Major
                  Found in salt/minion.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        for key, value in ret['data'].items():
                                            comment = '{0}\n\t\t{1}: {2}'.format(comment, key, value)
                                    else:
                    Severity: Major
                    Found in salt/output/highstate.py - About 45 mins to fix

                      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

                        Avoid deeply nested control flow statements.
                        Open

                                            if isinstance(cur_struct, (list, tuple)):
                                                for cur_ele in cur_struct:
                                                    found |= _compare(cmp_value, cur_ele)
                                            elif isinstance(cur_struct, dict):
                                                for _, cur_ele in six.iteritems(cur_struct):
                        Severity: Major
                        Found in salt/beacons/napalm_beacon.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if 'type' in interface_config and \
                                                      interface_config['type'] == 'equal':
                                                  if getattr(_if_stats, attr, None) == \
                                                          int(interface_config[attr]):
                                                      _diff = True
                          Severity: Major
                          Found in salt/beacons/network_info.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if 'battery' not in val or battery_level != val['battery']:
                                                        if ('battery' not in val or val['battery'] > _config['battery_low']) and \
                                                                        battery_level <= _config['battery_low']:
                                                            ret.append({'device': device, 'battery_level': battery_level, 'tag': 'battery_low'})
                            
                            
                            Severity: Major
                            Found in salt/beacons/adb.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if wm.watches[wd].auto_add != auto_add:
                                                      update = True
                                                  if update:
                              Severity: Major
                              Found in salt/beacons/inotify.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if update:
                                                        wm.update_watch(wd, mask=mask, rec=rec, auto_add=auto_add)
                                        elif os.path.exists(path):
                                Severity: Major
                                Found in salt/beacons/inotify.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 ps beacon should be a list of dicts
                                  Severity: Minor
                                  Found in salt/beacons/ps.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(event[field], bytes):
                                                          event[field] = salt.utils.stringutils.to_unicode(event[field])
                                                      event[field] = event[field].strip('\x00')
                                  Severity: Major
                                  Found in salt/beacons/wtmp.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if ind == 1:
                                                            event['cmd'] = field
                                                            continue
                                                        if ind % 2 != 0:
                                    Severity: Major
                                    Found in salt/beacons/sh.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if self.opts['master_failback'] and 'master_list' in self.opts:
                                                                  if self.opts['master'] != self.opts['master_list'][0]:
                                                                      schedule = {
                                                                         'function': 'status.ping_master',
                                                                         'seconds': self.opts['master_failback_interval'],
                                      Severity: Major
                                      Found in salt/minion.py - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language