saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if new_member['name'] == member:
                        modified_member = new_member
                        break

                #check for changes
Severity: Major
Found in salt/states/bigip.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if 'scaling_policy' not in action:
                            scaling_policy_actions_only = False
                        if ':self:' in action:
    Severity: Major
    Found in salt/states/boto_asg.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for line in key_file:
                              if line.startswith('#'):
                                  # Commented line
                                  continue
                              ssh_key = ssh_key + line
      Severity: Major
      Found in salt/states/esxi.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if remove_instance:
                                # create remove_ array
                                if 'remove_{0}'.format(instance) not in vmconfig['changed']:
                                    vmconfig['changed']['remove_{0}'.format(instance)] = []
        
        
        Severity: Major
        Found in salt/states/smartos.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if ret['changes'].get('deleted_tags'):
                                      comments.append(
                                          'The following tags {0} removed from the local '
                                          'checkout: {1}'.format(
                                              'would be' if __opts__['test']
          Severity: Major
          Found in salt/states/git.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if len(year) != 4:
                                        year = time.strftime('%Y')[:2] + year
            
            
            Severity: Major
            Found in salt/states/win_task.py - About 45 mins to fix

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

              def _write_config(config):
                  '''
                  writes /usbkey/config
                  '''
                  try:
              Severity: Minor
              Found in salt/states/smartos.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 'launch_config' not in ret['changes']:
                                      ret['changes']['launch_config'] = {}
                                  ret['changes']['launch_config']['deleted'] = asg['launch_config_name']
              Severity: Major
              Found in salt/states/boto_asg.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not msg:
                                        msg = 'There was an error resetting a syslog config \'{0}\'.' \
                                              'Please check debug logs.'.format(val)
                                    ret['comment'] = 'Error: {0}'.format(msg)
                Severity: Major
                Found in salt/states/esxi.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for config_env_var in val_config if isinstance(val_config, list) else json.loads(val_config):
                                          config_env_var = config_env_var.split('=')
                                          for img_env_var in val:
                                              if img_env_var.startswith('{0}='.format(config_env_var[0])):
                                                  val.remove(img_env_var)
                  Severity: Major
                  Found in salt/states/smartos.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        while image:
                                            image_count += 1
                                            __salt__['imgadm.delete'](image['manifest']['uuid'])
                                            if 'origin' in image['manifest']:
                                                image = __salt__['imgadm.get'](image['manifest']['origin'])
                    Severity: Major
                    Found in salt/states/smartos.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if collection in vmconfig['state'] and vmconfig['state'][collection] is not None:
                                              if prop in vmconfig['state'][collection]:
                                                  continue
                      
                                          # create remove_ array
                      Severity: Major
                      Found in salt/states/smartos.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if 'mac' in instance_config:
                                                instance_config['mac'] = instance_config['mac'].lower()
                                            vmconfig[prop].append(instance_config)
                        Severity: Major
                        Found in salt/states/smartos.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if not revs_match and not update_head:
                                                      # Repo content would not be modified but the remote
                                                      # URL would be modified, so we can't just say that
                                                      # the repo is up-to-date, we need to inform the
                                                      # user of the actions taken.
                          Severity: Major
                          Found in salt/states/git.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if vmconfig['current'][prop] == vmconfig['state'][prop]:
                                                    continue
                                            else:
                            Severity: Major
                            Found in salt/states/smartos.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if branch not in \
                                                              __salt__['git.list_branches'](
                                                                  target,
                                                                  user=user,
                                                                  password=password,
                              Severity: Major
                              Found in salt/states/git.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if 'launch_config' not in ret['changes']:
                                                        ret['changes']['launch_config'] = {}
                                                    ret['changes']['launch_config']['deleted'] = asg['launch_config_name']
                                Severity: Major
                                Found in salt/states/boto_asg.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                              if rev in all_local_tags:
                                                                  try:
                                                                      local_tag_sha1 = __salt__['git.rev_parse'](
                                                                          target,
                                                                          rev + '^{commit}',
                                  Severity: Major
                                  Found in salt/states/git.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if not revs_match:
                                                                if update_head:
                                                                    if fast_forward is True:
                                                                        actions.append(
                                                                            'Repository would be fast-forwarded from '
                                    Severity: Major
                                    Found in salt/states/git.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          if ':self:' in action:
                                                              action = action.replace(':self:', ':{0}:'.format(name))
                                                          new_actions.append(action)
                                      Severity: Major
                                      Found in salt/states/boto_asg.py - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language