saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if isinstance(crd[nk], list):
                            crd[nk].append(ret[i])
                        else:
                            crd[nk] = [crd[nk], ret[i]]
                    else:
Severity: Major
Found in salt/pillar/sql_base.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if neighbor_ip and neighbor_ip != neighbor.get('remote_address'):
                            # requested filtering by neighbors IP addr
                            continue
                        if ipnet_obj and neighbor.get('remote_address'):
    Severity: Major
    Found in salt/runners/bgp.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if matches is not None:
                                  name = matches.group(1).strip()
                                  alias = matches.group(2).strip()
      
      
      Severity: Major
      Found in salt/renderers/pyobjects.py - About 45 mins to fix

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

        def _cleanup(obj):
            if obj:
                if isinstance(obj, dict):
                    obj.pop('__', None)
                    for k, v in six.iteritems(obj):
        Severity: Minor
        Found in salt/pillar/makostack.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 name not in state_globals:
                                    raise ImportError(
                                        '\'{0}\' was not found in \'{1}\''.format(
                                            name,
                                            import_file
        Severity: Major
        Found in salt/renderers/pyobjects.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for item in record.get(key):
                                  ret[key] = item
                          if key in lists:
          Severity: Major
          Found in salt/pillar/pillar_ldap.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if not self.ignore_null or ret[i] is not None:
                                        crd[nk] = ret[i]
                    # Get key list and work backwards.  This is inner-out processing
                    ks = list(listify_dicts.keys())
            Severity: Major
            Found in salt/pillar/sql_base.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  for field in display_fields:
                                      if field in neighbor:
                                          row[field] = neighbor[field]
                                  rows.append(row)
              Severity: Major
              Found in salt/runners/bgp.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    for key in salt.utils.args.split_input(search_target):
                                        if fnmatch.fnmatch(target, key):
                                            _match = True
                
                
                Severity: Major
                Found in salt/runners/jobs.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if minion_id in match:
                                          ngroup_dir = os.path.join(
                                              nodegroups_dir, six.text_type(nodegroup))
                                          ngroup_pillar = salt.utils.dictupdate.merge(ngroup_pillar,
                                              _construct_pillar(ngroup_dir,
                  Severity: Major
                  Found in salt/pillar/file_tree.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if len(skey) > 1 and key.rfind('()') > 0:
                                            rkey = skey[0].rstrip(__opts__['pepa_delimiter'])
                                            operator = skey[1]
                    
                    
                    Severity: Major
                    Found in salt/pillar/pepa.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for key, val in six.iteritems(arg):
                                                  if key == 'names':
                                                      for _name in val:
                                                          if _name not in names:
                                                              names.append(_name)
                      Severity: Major
                      Found in salt/state.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if isinstance(item, six.string_types) and item not in env_matches:
                                                    env_matches.append(item)
                                return matches
                        Severity: Major
                        Found in salt/pillar/__init__.py - About 45 mins to fix

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

                              def _run_check(self, low_data):
                                  '''
                                  Check that unless doesn't return 0, and that onlyif returns a 0.
                                  '''
                                  ret = {'result': False, 'comment': []}
                          Severity: Minor
                          Found in salt/state.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 len(comps) >= 2:
                                                      # Merge the comps
                                                      comps[1] = '.'.join(comps[1:len(comps)])
                                                  high[name] = {
                          Severity: Major
                          Found in salt/state.py - About 45 mins to fix

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

                            def ext_pillar(minion_id, pillar, *args, **kwargs):
                                stack = {}
                                stack_config_files = list(args)
                                traverse = {
                                    'pillar': functools.partial(salt.utils.data.traverse_dict_and_list, pillar),
                            Severity: Minor
                            Found in salt/pillar/stack.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 key in immutable:
                                                    log.warning('Key %s is immutable, changes are not allowed', key)
                                                elif rkey in immutable:
                                                    log.warning("Key %s is immutable, changes are not allowed", rkey)
                                                elif operator == 'merge()' or operator == 'imerge()':
                            Severity: Major
                            Found in salt/pillar/pepa.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if state == 'require' or state == 'watch':
                                                          continue
                                                      errors.append(('No function declared in state \'{0}\' in'
                              Severity: Major
                              Found in salt/state.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if hasattr(data, 'availableField'):
                                                            vmware_pillar[pillar_key]['annotations'] = {}
                                                            for availableField in data.availableField:
                                                                for customValue in data.customValue:
                                                                    if availableField.key == customValue.key:
                                Severity: Major
                                Found in salt/pillar/vmware_pillar.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          for comp in ctop[saltenv][tgt]:
                                                              if isinstance(comp, dict):
                                                                  if 'match' in comp:
                                                                      matches.append(comp)
                                                                  if 'order' in comp:
                                  Severity: Major
                                  Found in salt/pillar/__init__.py - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language