saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def reload_core(host=None, core_name=None):
    '''
    MULTI-CORE HOSTS ONLY
    Load a new core from the same configuration as an existing registered core.
    While the "new" core is initializing, the "old" one will continue to accept
Severity: Minor
Found in salt/modules/solr.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 parse_hosts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def parse_hosts(hostsfile='/etc/hosts', hosts=None):
    '''
    Parse /etc/hosts file.

    CLI Example:
Severity: Minor
Found in salt/modules/dnsutil.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 _pre_index_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def _pre_index_check(handler, host=None, core_name=None):
    '''
    PRIVATE METHOD - MASTER CALL
    Does a pre-check to make sure that all the options are set and that
    we can talk to solr before trying to send a command to solr. This
Severity: Minor
Found in salt/modules/solr.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 _getFullPolicyName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def _getFullPolicyName(policy_item,
                       policy_name,
                       return_full_policy_names,
                       adml_language):
    '''
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

                    for i, item in enumerate(element_valuenames):
                        expected_string = expected_string + b''.join(['['.encode('utf-16-le'),
                                                                      reg_key,
                                                                      encoded_null,
                                                                      encoded_semicolon,
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

      Avoid deeply nested control flow statements.
      Open

                          for regedit in _regedits:
                              log.debug('%s is a Registry policy', regedit)
                              # if the value setting is None or "(value not set)", we will delete the value from the registry
                              if _regedits[regedit]['value'] is not None and _regedits[regedit]['value'] != '(value not set)':
                                  _ret = __utils__['reg.set_value'](
      Severity: Major
      Found in salt/modules/win_lgpo.py - About 45 mins to fix

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

        def _aws_encode_changebatch(o):
            '''
            helper method to process a change batch & encode the bits which need encoding.
            '''
            change_idx = 0
        Severity: Minor
        Found in salt/modules/boto3_route53.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 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 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 policy_name in _policydata.policies[p_class]['policies']:
                                      _pol = _policydata.policies[p_class]['policies'][policy_name]
                                  else:
                                      for policy in _policydata.policies[p_class]['policies']:
                                          if _policydata.policies[p_class]['policies'][policy]['Policy'].upper() == \
              Severity: Major
              Found in salt/modules/win_lgpo.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if ctl_key not in ret:
                                        ret[ctl_key] = {}
                                    ret[ctl_key][loc_set[0]] = loc_set[1]
                Severity: Major
                Found in salt/modules/localemod.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')
                              if check_deleted:
                  Severity: Major
                  Found in salt/modules/win_lgpo.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if policy_namespace not in unpathed_dict:
                                            unpathed_dict[policy_namespace] = {}
                                        unpathed_dict[policy_namespace][full_names[policy_namespace][policy_item]] = policy_item
                    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

                        Avoid deeply nested control flow statements.
                        Open

                                            if policy_info['ScriptIni']['SettingName'].lower() in [z.lower() for z in _existingData[policy_info['ScriptIni']['Section']].keys()]:
                                                return _existingData[policy_info['ScriptIni']['Section']][policy_info['ScriptIni']['SettingName'].lower()]
                                            else:
                                                return None
                                        else:
                        Severity: Major
                        Found in salt/modules/win_lgpo.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if 'Value' in rr['ResourceRecords'][x]:
                                                      rr['ResourceRecords'][x]['Value'] = _aws_decode(rr['ResourceRecords'][x]['Value'])
                                                  x += 1
                          Severity: Major
                          Found in salt/modules/boto3_route53.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if label_item.text:
                                                    return (prepended_text + ' ' + label_item.text.rstrip().rstrip(':')).lstrip()
                                        elif the_localname == 'decimalTextBox' \
                            Severity: Major
                            Found in salt/modules/win_lgpo.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if not_configured_policy_namespace not in full_names:
                                                      full_names[not_configured_policy_namespace] = {}
                                                  full_names[not_configured_policy_namespace][not_configured_policy.attrib['name']] = _getFullPolicyName(
                              Severity: Major
                              Found in salt/modules/win_lgpo.py - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language