saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not _write_secedit_data(_secedits):
                        msg = ('Error while attempting to set policies via '
                               'secedit. Some changes may not be applied as '
                               'expected')
                        raise CommandExecutionError(msg)
Severity: Major
Found in salt/modules/win_lgpo.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if k == 0:
                                do_test = False
                        if do_test and isinstance(k, int) and item & k == k:
    Severity: Major
    Found in salt/modules/win_lgpo.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if not value == 'None':
                                  # The value is not None, make the change
                                  row['Inclusion Setting'] = auditpol_values[value]
                                  row['Setting Value'] = value
                                  log.debug('LGPO: Setting {0} to {1}'
      Severity: Major
      Found in salt/modules/win_lgpo.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for p_item in presentation_element.getchildren():
                                if p_item == result:
                                    break
                                else:
                                    if etree.QName(p_item.tag).localname == 'text':
        Severity: Major
        Found in salt/modules/win_lgpo.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for setting in _netshs:
                                  log.debug('Setting firewall policy: %s', setting)
                                  log.debug(_netshs[setting])
                                  _set_netsh_value(**_netshs[setting])
          
          
          Severity: Major
          Found in salt/modules/win_lgpo.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                for _modal_set in _modal_sets:
                                    try:
                                        _existingModalData = win32net.NetUserModalsGet(None, _modal_set)
                                        _newModalSetData = dictupdate.update(_existingModalData, _modal_sets[_modal_set])
                                        log.debug('NEW MODAL SET = %s', _newModalSetData)
            Severity: Major
            Found in salt/modules/win_lgpo.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if 'key' in temp_pol.attrib:
                                      temp_pol = _updatePolicyElements(temp_pol, temp_pol.attrib['key'])
                                  policydefs_policies_xpath(t_policy_definitions)[0].append(temp_pol)
              Severity: Major
              Found in salt/modules/win_lgpo.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    for elements_item in ELEMENTS_XPATH(admx_policy):
                                        for child_item in elements_item.getchildren():
                                            this_element_name = _getFullPolicyName(
                                                policy_item=child_item,
                                                policy_name=child_item.attrib['id'],
                Severity: Major
                Found in salt/modules/win_lgpo.py - About 45 mins to fix

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

                  def mkconfig(config=None,
                               tmp=None,
                               id_=None,
                               approve_key=True,
                               pub_key=None,
                  Severity: Minor
                  Found in salt/modules/seed.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 vtype == 'REG_DWORD' or vtype == 'REG_QWORD':
                                          if value:
                                              if vtype == 'REG_DWORD':
                                                  for v in struct.unpack(b'I', value):
                                                      value = v
                  Severity: Major
                  Found in salt/modules/win_lgpo.py - About 45 mins to fix

                    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

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

                          def _dasd_conversion(cls, val, **kwargs):
                              '''
                              converts 0/1/2 for dasd reg key
                              '''
                              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 prepended_text.endswith('.'):
                                              prepended_text = ''
                                  if the_localname == 'textBox' \
                      Severity: Major
                      Found in salt/modules/win_lgpo.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if installed == pkg_version:
                                                    ret[pkg] = ''
                                                else:
                                                    ret[pkg] = pkg_version
                                        except ValueError:
                        Severity: Major
                        Found in salt/modules/apkpkg.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if not _ret:
                                                  msg = ('Error while attempting to write Administrative Template Policy data.'
                                                         '  Some changes may not be applied as expected')
                                                  raise CommandExecutionError(msg)
                                  return True
                          Severity: Major
                          Found in salt/modules/win_lgpo.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if this_element_value is not None:
                                                    element_valuenames = ['{0}{1}'.format(
                                                        element.attrib['valuePrefix'], k) for k in element_valuenames]
                                        else:
                            Severity: Major
                            Found in salt/modules/win_lgpo.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if etree.QName(admx_item).localname == 'policy':
                                                      if admx_item not in admx_policies:
                                                          admx_policies.append(admx_item)
                                                  else:
                                                      for policy_item in POLICY_ANCESTOR_XPATH(admx_item):
                              Severity: Major
                              Found in salt/modules/win_lgpo.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if not getattr(adml_search_result, 'text', '').strip() == policy_name:
                                                        adml_to_remove.append(adml_search_result)
                                                    else:
                                                        if hierarchy:
                                                            log.debug('we have hierarchy of %s', hierarchy)
                                Severity: Major
                                Found in salt/modules/win_lgpo.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if hierarchy_item in policy_vals[policy_namespace]:
                                                          tdict = {}
                                                          first_item = True
                                                          for item in hierarchy[policy_namespace][hierarchy_item]:
                                                              newdict = {}
                                  Severity: Major
                                  Found in salt/modules/win_lgpo.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if 'class' in this_policy.attrib:
                                                                if this_policy.attrib['class'] == registry_class or this_policy.attrib['class'] == 'Both':
                                                                    if 'key' in this_policy.attrib:
                                                                        this_key = this_policy.attrib['key']
                                                                    else:
                                    Severity: Major
                                    Found in salt/modules/win_lgpo.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language