saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not perms:
                        for perm in cur_perms['Not Inherited'][user_name][access_mode]['permissions']:
                            for flag in flags().ace_perms[obj_type]['advanced']:
                                if flags().ace_perms[obj_type]['advanced'][flag] == perm:
                                    perm_flag = flag
Severity: Major
Found in salt/utils/win_dacl.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if user not in changes:
                            changes[user] = {}
                        changes[user][access_mode] = new_perms[user]['perms']
    Severity: Major
    Found in salt/utils/win_dacl.py - About 45 mins to fix

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

      def copy_security(source,
                        target,
                        obj_type='file',
                        copy_owner=True,
                        copy_group=True,
      Severity: Minor
      Found in salt/utils/win_dacl.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 user_name in cur_perms['Not Inherited'] and \
                                  access_mode in cur_perms['Not Inherited'][user_name]:
                              for flag in flags().ace_prop[obj_type]:
                                  if flags().ace_prop[obj_type][flag] == cur_perms['Not Inherited'][user_name][access_mode]['applies to']:
                                      at_flag = flag
      Severity: Major
      Found in salt/utils/win_dacl.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if i == old:
                                v[x] = new
                        x = x + 1
        Severity: Major
        Found in salt/utils/saltclass.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if obj_type == 'file':
                                  applies_to = 'this_folder_subfolders_files'
                              elif 'registry' in obj_type:
                                  applies_to = 'this_key_subkeys'
                      else:
          Severity: Major
          Found in salt/utils/win_dacl.py - About 45 mins to fix

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

            def os_script(os_, vm_=None, opts=None, minion=''):
                '''
                Return the script as a string for the specific os
                '''
                if minion:
            Severity: Minor
            Found in salt/utils/cloud.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(i, six.string_types):
                                    b = find_and_process_re(i, v, k, b, expanded)
            
            
            Severity: Major
            Found in salt/utils/saltclass.py - About 45 mins to fix

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

              def vb_machine_exists(name):
                  '''
                  Checks in with the hypervisor to see if the machine with the given name is known
                  @param name:
                  @type name:
              Severity: Minor
              Found in salt/utils/virtualbox.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(after_items_update[name], list):
                                          after_items_update[name].extend(data)
                                  else:
              Severity: Major
              Found in salt/utils/schema.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    for perm in cur_perms['Not Inherited'][user_name][access_mode]['permissions']:
                                        for flag in flags().ace_perms[obj_type]['basic']:
                                            if flags().ace_perms[obj_type]['basic'][flag] == perm:
                                                perm_flag = flag
                                                for flag1 in flags().ace_perms[obj_type]['basic']:
                Severity: Major
                Found in salt/utils/win_dacl.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if __opts__['test'] is True:
                                          if 'remove_perms' not in ret['changes']:
                                              ret['changes']['remove_perms'] = {}
                                          ret['changes']['remove_perms'].update(
                                              {user_name: cur_perms['Not Inherited'][user_name]})
                  Severity: Major
                  Found in salt/utils/win_dacl.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if not cur_perms['Not Inherited'][user_name][access_mode]['applies to'] == applies_to_text:
                                            if user not in changes:
                                                changes[user] = {}
                                            changes[user]['applies_to'] = applies_to
                    
                    
                    Severity: Major
                    Found in salt/utils/win_dacl.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          for flag in flags().ace_prop[obj_type]:
                                              if flags().ace_prop[obj_type][flag] == cur_perms['Not Inherited'][user_name]['deny']['applies to']:
                                                  at_flag = flag
                                                  for flag1 in flags().ace_prop[obj_type]:
                                                      if flags().ace_prop[obj_type][flag1] == at_flag:
                      Severity: Major
                      Found in salt/utils/win_dacl.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                with salt.utils.files.fopen(true_path, 'rb') as handle:
                                                    plist = plistlib.load(handle)
                        
                        
                        Severity: Major
                        Found in salt/utils/mac_utils.py - About 45 mins to fix

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

                              def get_definition(self):
                                  '''Returns the definition of the complex item'''
                          
                                  serialized = super(ComplexSchemaItem, self).serialize()
                                  # Adjust entries in the serialization
                          Severity: Minor
                          Found in salt/utils/schema.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 prepare_kwargs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def prepare_kwargs(all_kwargs, class_init_kwargs):
                              '''
                              Filter out the kwargs used for the init of the class and the kwargs used to
                              invoke the command required.
                          
                          
                          Severity: Minor
                          Found in salt/utils/args.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) > 1 or comps[0] != 'tmp':
                                                  ret = root_cmd(
                                                      'chown {0} "{1}"'.format(username, tmp_dir),
                                                      tty, sudo, **ssh_kwargs
                                                  )
                          Severity: Major
                          Found in salt/utils/cloud.py - About 45 mins to fix

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

                                def __init__(self, id_, module, func, **kwargs):
                                    self.id_ = id_
                                    self.module = module
                                    self.func = func
                            
                            
                            Severity: Minor
                            Found in salt/utils/pyobjects.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 force_minion_config:
                                                    deploy_command += ' -F'
                                                if make_syndic is True:
                            Severity: Major
                            Found in salt/utils/cloud.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language