saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def bootstrap(version='develop',
              script=None,
              hosts='',
              script_args='',
              roster='flat',
Severity: Minor
Found in salt/runners/manage.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(result, list):
                        # Errors were detected
                        raise CommandExecutionError(
                            'Failed up update winrepo remotes: {0}'.format(
                                '\n'.join(result)
Severity: Major
Found in salt/runners/winrepo.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if 'name' not in result:
                            # Highstate output dict, the results are actually nested
                            # one level down.
                            key = next(iter(result))
                            result = result[key]
    Severity: Major
    Found in salt/runners/winrepo.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if 'connection_stats' in display_fields:
                              connection_stats = '{state} {active}/{received}/{accepted}/{damped}'.format(
                                  state=neighbor.get('connection_state', -1),
                                  active=neighbor.get('active_prefix_count', -1),
                                  received=neighbor.get('received_prefix_count', -1),
      Severity: Major
      Found in salt/runners/bgp.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if fnmatch.fnmatch(ret[item]['Function'], key):
                                _match = True
        
        
        Severity: Major
        Found in salt/runners/jobs.py - About 45 mins to fix

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

          def _find_vm(name, data, quiet=False):
              '''
              Scan the query data for the named VM
              '''
              for hv_ in data:
          Severity: Minor
          Found in salt/runners/virt.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 ipnet_obj and neighbor.get('remote_address'):
                                  neighbor_ip_obj = IPAddress(neighbor.get('remote_address'))
                                  if neighbor_ip_obj not in ipnet_obj:
                                      # Neighbor not in this network
                                      continue
          Severity: Major
          Found in salt/runners/bgp.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if 'interface_description' in display_fields or 'interface_name' in display_fields:
                                    net_find = __salt__['net.interfaces'](device=minion,
                                                                          ipnet=neighbor.get('remote_address'),
                                                                          display=False)
                                    if net_find:
            Severity: Major
            Found in salt/runners/bgp.py - About 45 mins to fix

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

              def render(genshi_data, saltenv='base', sls='', method='xml', **kws):
                  '''
                  Render a Genshi template. A method should be passed in as part of the
                  kwargs. If no method is passed in, xml is assumed. Valid methods are:
              
              
              Severity: Minor
              Found in salt/renderers/genshi.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 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 self.as_list:
                                            # Make list
                                            temp = {}
                                            crd[ret[i]] = [crd[ret[i]], temp]
                                            crd = temp
                Severity: Major
                Found in salt/pillar/sql_base.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if not isinstance(crd[ret[nk]], list):
                                              crd[ret[nk]] = [crd[ret[nk]]]
                                          # if it's already a list, do nothing
                                      else:
                  Severity: Major
                  Found in salt/pillar/sql_base.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if k.startswith(prefix):
                                            tmplctx[k[len(prefix):]] = tmplctx[k]
                                            del tmplctx[k]
                            else:
                    Severity: Major
                    Found in salt/renderers/stateconf.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if '=' in item:
                                              skey, sval = item.split('=', 1)
                                              if skey not in data:
                                                  data[skey] = [sval]
                                              else:
                      Severity: Major
                      Found in salt/pillar/pillar_ldap.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            for key in search_metadata:
                                                if key in ret[item]['Metadata']:
                                                    if ret[item]['Metadata'][key] == search_metadata[key]:
                                                        _match = True
                                        else:
                        Severity: Major
                        Found in salt/runners/jobs.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if id(crd) not in listify:
                                                      listify[id(crd)] = []
                                                      listify_dicts[id(crd)] = crd
                                                  if nk not in listify[id(crd)]:
                          Severity: Major
                          Found in salt/pillar/sql_base.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if nk not in listify[id(crd)]:
                                                        listify[id(crd)].append(nk)
                                                # Collision detection
                                                if self.as_list and (nk in crd):
                            Severity: Major
                            Found in salt/pillar/sql_base.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if isinstance(arg, dict) and next(iter(arg)) == 'name':
                                                      break
                                              else:
                              Severity: Major
                              Found in salt/renderers/stateconf.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if 'vrf' in display_fields:
                                                        row['vrf'] = vrf
                                                    if 'connection_stats' in display_fields:
                                Severity: Major
                                Found in salt/runners/bgp.py - About 45 mins to fix

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

                                  def _do_search(conf):
                                      '''
                                      Builds connection and search arguments, performs the LDAP search and
                                      formats the results as a dictionary appropriate for pillar use.
                                      '''
                                  Severity: Minor
                                  Found in salt/pillar/pillar_ldap.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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language