saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if ssh_kwargs['username'] != 'root':
                        root_cmd(
                            'chown {0} \'{1}\''.format(
                                ssh_kwargs['username'], remote_dir
                            ),
Severity: Major
Found in salt/utils/cloud.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if not isinstance(script_env, dict):
                            raise SaltCloudSystemExit(
                                'The \'script_env\' configuration setting NEEDS '
                                'to be a dictionary not a {0}'.format(
                                    type(script_env)
    Severity: Major
    Found in salt/utils/cloud.py - About 45 mins to fix

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

              def _rename_atomic(src, dst):  # pylint: disable=E0102
                  tra = _CreateTransaction(None, 0, 0, 0, 0, 1000, 'Atomic rename')
                  if tra == -1:
                      return False
                  try:
      Severity: Minor
      Found in salt/utils/atomicfile.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 join has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def join(*parts, **kwargs):
          '''
          This functions tries to solve some issues when joining multiple absolute
          paths on both *nix and windows platforms.
      
      
      Severity: Minor
      Found in salt/utils/path.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 list_nodes_select has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def list_nodes_select(nodes, selection, call=None):
          '''
          Return a list of the VMs that are on the provider, with select fields
          '''
          if call == 'action':
      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

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

      def cidr_to_ipv4_netmask(cidr_bits):
          '''
          Returns an IPv4 netmask
          '''
          try:
      Severity: Minor
      Found in salt/utils/network.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 missing_node_cache has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def missing_node_cache(prov_dir, node_list, provider, opts):
          '''
          Check list of nodes to see if any nodes which were previously known about
          in the cache have been removed from the node list.
      
      
      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 ret:
                              raise SaltCloudSystemExit(
                                  'Can\'t set ownership for {0}'.format(
                                      preseed_minion_keys_tempdir))
      
      
      Severity: Major
      Found in salt/utils/cloud.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if make_master is True:
                                deploy_command += ' -M'
                            if make_minion is False:
        Severity: Major
        Found in salt/utils/cloud.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for key, value in six.iteritems(script_env):
                                  environ_script_contents.append(
                                      'setenv {0} \'{1}\' >/dev/null 2>&1 || '
                                      'export {0}=\'{1}\''.format(key, value)
                                  )
          Severity: Major
          Found in salt/utils/cloud.py - About 45 mins to fix

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

                def _get_cached_mine_data(self, *minion_ids):
                    # Return one dict with the cached mine data of the targeted minions
                    mine_data = dict([(minion_id, {}) for minion_id in minion_ids])
                    if (not self.opts.get('minion_data_cache', False)
                            and not self.opts.get('enforce_mine_cache', False)):
            Severity: Minor
            Found in salt/utils/master.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 clean_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def clean_path(root, path, subdir=False):
                '''
                Accepts the root the path needs to be under and verifies that the path is
                under said root. Pass in subdir=True if the path can result in a
                subdirectory of the root instead of having to reside directly in the root
            Severity: Minor
            Found in salt/utils/verify.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 sound in sounds:
                                    ret['message'] = 'Valid sound {0}.'.format(sound)
                                    ret['res'] = True
                                else:
                                    ret['message'] = 'Warning: {0} not a valid sound.'.format(sound)
            Severity: Major
            Found in salt/utils/pushover.py - About 45 mins to fix

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

              def filter_event(tag, data, defaults):
                  '''
                  Accept a tag, a dict and a list of default keys to return from the dict, and
                  check them against the cloud configuration for that tag
                  '''
              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 make_minion is False:
                                      deploy_command += ' -N'
                                  if keep_tmp is True:
              Severity: Major
              Found in salt/utils/cloud.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if keep_tmp is True:
                                        deploy_command += ' -K'
                                    if preseed_minion_keys is not None:
                Severity: Major
                Found in salt/utils/cloud.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if 'when' in data:
                                              data['_run'] = True
                                      else:
                  Severity: Major
                  Found in salt/utils/schedule.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if ret:
                                            log.info('[%s] Output: %s', cmd_line, ret)
                    
                        # TODO: ensure we send the correct return value
                        return True
                    Severity: Major
                    Found in salt/utils/cloud.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if is_console_configured():
                                              log.critical(msg)
                                          else:
                                              sys.stderr.write("CRITICAL: {0}\n".format(msg))
                      
                      
                      Severity: Major
                      Found in salt/utils/verify.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if jobcount >= data['maxrunning']:
                                                    log.debug(
                                                        'schedule.handle_func: The scheduled job '
                                                        '%s was not started, %s already running',
                                                        data['name'], data['maxrunning']
                        Severity: Major
                        Found in salt/utils/schedule.py - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language