saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if isinstance(fileopts[comps[0]], six.string_types):
                        temp = fileopts[comps[0]]
                        fileopts[comps[0]] = [temp]
                    fileopts[comps[0]].append(comps[1].strip())
Severity: Major
Found in salt/modules/dnsmasq.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if _pol['NetUserModal']['Modal'] not in modal_returns:
                            modal_returns[_pol['NetUserModal']['Modal']] = win32net.NetUserModalsGet(
                                    None,
                                    _pol['NetUserModal']['Modal'])
                        class_vals[policy_name] = modal_returns[_pol['NetUserModal']['Modal']][_pol['NetUserModal']['Option']]
    Severity: Major
    Found in salt/modules/win_lgpo.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for setting in _advaudits:
                              log.debug('Setting Advanced Audit policy: {0}'.format(setting))
                              log.debug(_advaudits[setting])
                              _set_advaudit_value(**_advaudits[setting])
      
      
      Severity: Major
      Found in salt/modules/win_lgpo.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if _regexSearchRegPolData(re.escape(search_string), policy_file_data):
                                configured_items = configured_items + 1
                                log.debug('found the search string in the pol file,'
                                          '%s of %s items for policy %s are '
                                          'configured in registry.pol',
        Severity: Major
        Found in salt/modules/win_lgpo.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if (len(admx_search_results) == 1 or hierarchy) and not multiple_adml_entries:
                                  found = False
                                  for search_result in admx_search_results:
                                      found = False
                                      if hierarchy:
          Severity: Major
          Found in salt/modules/win_lgpo.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if requested_val is not None:
                                    this_element_value = six.text_type(requested_val).encode('utf-16-le')
                    elif etree.QName(element).localname == 'text':
            Severity: Major
            Found in salt/modules/win_lgpo.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if _pol:
                                      # transform and validate the setting
                                      _value = _transform_value(
                                          value=policies[p_class][policy_name],
                                          policy=_policydata.policies[p_class]['policies'][policy_key_name],
              Severity: Major
              Found in salt/modules/win_lgpo.py - About 45 mins to fix

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

                def atrm(*args):
                    '''
                    Remove jobs from the queue.
                
                    CLI Example:
                Severity: Minor
                Found in salt/modules/at.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 _dasd_reverse_conversion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _dasd_reverse_conversion(cls, val, **kwargs):
                        '''
                        converts DASD String values to the reg_sz value
                        '''
                        if val is not None:
                Severity: Minor
                Found in salt/modules/win_lgpo.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 'lgpo_section' in _pol:
                                        firstItem = True
                                        tdict = {}
                                        for level in reversed(_pol['lgpo_section']):
                                            newdict = {}
                Severity: Major
                Found in salt/modules/win_lgpo.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for lsaright in _lsarights:
                                          _existingUsers = None
                                          if not cumulative_rights_assignments:
                                              _existingUsers = _getRightsAssignments(
                                                      _lsarights[lsaright]['policy']['LsaRights']['Option'])
                  Severity: Major
                  Found in salt/modules/win_lgpo.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if not __salt__['file.file_exists'](adml_file):
                                            log.info('An ADML file in the specified ADML language '
                                                     'code %s does not exist for the ADMX "%s", '
                                                     'the fallback language will be tried.',
                                                     language[:2], t_admfile)
                    Severity: Major
                    Found in salt/modules/win_lgpo.py - About 45 mins to fix

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

                      def refresh_db(force=False, **kwargs):
                          '''
                          Use pkg update to get latest pkg_summary
                      
                          force
                      Severity: Minor
                      Found in salt/modules/pkgin.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 this_policynamespace not in policy_vals:
                                              policy_vals[this_policynamespace] = {}
                                          policy_vals[this_policynamespace][this_policyname] = this_policy_setting
                      Severity: Major
                      Found in salt/modules/win_lgpo.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if element_only_enabled_disabled:
                                                if required_elements \
                                                            and len(configured_elements) == len(required_elements):
                                                    if policy_disabled_elements == len(required_elements):
                                                        log.debug('%s is disabled by all enum elements', this_policyname)
                        Severity: Major
                        Found in salt/modules/win_lgpo.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if local_key_fingerprint == line_fingerprint:
                                                      lkeygrip = next(local_keys2).split('=')
                                                      local_keygrip_to_use = lkeygrip[1].lstrip().rstrip()
                                                      break
                                      except StopIteration:
                          Severity: Major
                          Found in salt/modules/debuild_pkgbuild.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if name not in beacons:
                                                        ret['result'] = True
                                                        ret['comment'] = 'Deleted beacon: {0}.'.format(name)
                                                        return ret
                                                elif event_ret:
                            Severity: Major
                            Found in salt/modules/beacons.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if 'enabled' in beacons and beacons['enabled']:
                                                          ret['result'] = True
                                                          ret['comment'] = 'Enabled beacons on minion.'
                                                      else:
                                                          ret['result'] = False
                              Severity: Major
                              Found in salt/modules/beacons.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if not os.path.exists(target_base):
                                                        os.makedirs(target_base, mode=0o755)
                                                        __salt__['file.chown'](target_base, user, None)
                                
                                
                                Severity: Major
                                Found in salt/modules/pip.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      for req in rq_:
                                                          req = salt.utils.stringutils.to_unicode(req)
                                                          try:
                                                              req_pkg, _ = req.split('==')
                                                              if req_pkg in pkgs:
                                  Severity: Major
                                  Found in salt/modules/pip.py - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language