saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not _ret:
                        _ret = __salt__['boto_ec2.release_eip_address'](public_ip=None,
                                                                        allocation_id=eip_alloc['allocation_id'],
                                                                        region=region,
                                                                        key=key,
Severity: Major
Found in salt/states/boto_ec2.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if not __salt__['boto_ec2.delete_tags'](resource_ids=instance_id, tags=remove,
                                                                region=region, key=key, keyid=keyid,
                                                                profile=profile):
                            msg = "Error while deleting tags on instance {0}".format(instance_name if
                                                                                    instance_name else name)
    Severity: Major
    Found in salt/states/boto_ec2.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if __opts__.get('test'):
                              ret['result'] = None
                              ret['comment'] = 'User roles "{0}" will been updated'.format(name)
                              return ret
                          addargs = dict({'user': name, 'role': role,
      Severity: Major
      Found in salt/states/keystone.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if local_dst_addrs[idx].lower() != remote_dst_addrs[idx].lower():
                                ret['changes']['destination_address_prefixes'] = {
                                    'old': rule.get('destination_address_prefixes'),
                                    'new': destination_address_prefixes
                                }
        Severity: Major
        Found in salt/states/azurearm_network.py - About 45 mins to fix

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

          def configmap_present(
                  name,
                  namespace='default',
                  data=None,
                  source=None,
          Severity: Minor
          Found in salt/states/kubernetes.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 local_src_addrs[idx].lower() != remote_src_addrs[idx].lower():
                                  ret['changes']['source_address_prefixes'] = {
                                      'old': rule.get('source_address_prefixes'),
                                      'new': source_address_prefixes
                                  }
          Severity: Major
          Found in salt/states/azurearm_network.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if 'roles' in ret['changes']:
                                    ret['changes']['roles'].append(oldrole)
                                else:
                                    ret['changes']['roles'] = [oldrole]
                else:
            Severity: Major
            Found in salt/states/keystone.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for cid in disconnected_containers:
                                          try:
                                              cinfo = __salt__['docker.inspect_container'](cid)
                                              netinfo = cinfo['NetworkSettings']['Networks'][name]
                                              # Links and Aliases will be None if not
              Severity: Major
              Found in salt/states/docker_network.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if attr not in entry_status['mentioned_attributes']:
                                        to_delete.add(attr)
                                for attr in to_delete:
                Severity: Major
                Found in salt/states/ldap.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if existing_vals:
                                          entry[attr] = existing_vals
                              elif directive == 'replace':
                  Severity: Major
                  Found in salt/states/ldap.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if 'ipv4addr' in addr:
                                            obj_addrs.append(addr['ipv4addr'])
                                if 'ipv6addrs' in obj:
                    Severity: Major
                    Found in salt/states/infoblox_host_record.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if n:
                                                  op = 'modify'
                                                  assert o != n
                                                  __salt__['ldap3.change'](l, dn, o, n)
                                              else:
                      Severity: Major
                      Found in salt/states/ldap.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if key_name.endswith('Address'):
                                                    connect_kwargs[arg_name] = \
                                                        connect_kwargs[arg_name].rsplit('/', 1)[0]
                                    try:
                        Severity: Major
                        Found in salt/states/docker_network.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if 'ipv6addr' in addr:
                                                  obj_addrs.append(addr['ipv6addr'])
                          
                                      # replace func:nextavailableip: if an ip address is already found in that range.
                                      if 'ipv4addrs' in data:
                          Severity: Major
                          Found in salt/states/infoblox_host_record.py - About 45 mins to fix

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

                            def dashboard_absent(
                                    name,
                                    hosts=None,
                                    profile='grafana'):
                                '''
                            Severity: Minor
                            Found in salt/states/grafana.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 'ipv4addr' in addr:
                                                    addrobj = addr['ipv4addr']
                                                    if addrobj.startswith('func:nextavailableip:'):
                                                        found_matches = 0
                                                        for ip in obj_addrs:
                            Severity: Major
                            Found in salt/states/infoblox_host_record.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if item_id_value in [value]:
                                                      item_create_required = False
                              
                                  # constraints match on '(id:<id>)'
                                  elif item in ['constraint']:
                              Severity: Major
                              Found in salt/states/pcs.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if line_key == test_key:
                                                        keys_match = True
                                
                                                # if the key was found in the line and separation was successful
                                                if keys_match:
                                Severity: Major
                                Found in salt/states/file.py - About 45 mins to fix

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

                                  def _check_touch(name, atime, mtime):
                                      '''
                                      Check to see if a file needs to be updated or created
                                      '''
                                      ret = {
                                  Severity: Minor
                                  Found in salt/states/file.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 not exc.strerror.startswith('Path not found'):
                                                              errors.append(exc.strerror)
                                  
                                  
                                  Severity: Major
                                  Found in salt/states/file.py - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language