saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if word == 'not':
                            if not results[-1] in ('&', '|', '('):
                                results.append('&')
                            results.append('(')
                            results.append(six.text_type(set(minions)))
Severity: Major
Found in salt/utils/minions.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if decomposed:
                                words = decomposed + words
                            continue
    Severity: Major
    Found in salt/utils/minions.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for field in hide_fields:
                              if item == field:
                                  log_data[item] = 'XXXXXXXXXX'
                  log.trace('Request POST Data: %s', pprint.pformat(log_data))
      Severity: Major
      Found in salt/utils/http.py - About 45 mins to fix

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

        def string_to_value(value):
            temp = value.lower()
            result = None
            if temp == "true":
                result = True
        Severity: Minor
        Found in salt/utils/namecheap.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 isinstance(value, novaclient.base.Manager):
                                    continue
                                if value.__class__.__name__ == attr:
        Severity: Major
        Found in salt/utils/openstack/nova.py - About 45 mins to fix

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

              def _fetch(resources, name_or_id):
                  ret = []
                  for resource in resources:
                      if resource['id'] == name_or_id:
                          return resource
          Severity: Minor
          Found in salt/utils/openstack/neutron.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 self.__fun_check(ind[valid], fun, fun_args, fun_kwargs):
                                          return True
                  except TypeError:
          Severity: Major
          Found in salt/utils/minions.py - About 45 mins to fix

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

                def send_signal_to_processes(self, signal_):
                    if (salt.utils.platform.is_windows() and
                            signal_ in (signal.SIGTERM, signal.SIGINT)):
                        # On Windows, the subprocesses automatically have their signal
                        # handlers invoked. If you send one of these signals while the
            Severity: Minor
            Found in salt/utils/process.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 value.__class__.__name__ == attr:
                                        setattr(connection, key, extension.manager_class(connection))
            
            
            Severity: Major
            Found in salt/utils/openstack/nova.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if idx < len(config):
                                      continue
                                  _namespace = '[{0}]'.format(idx)
              Severity: Major
              Found in salt/utils/configcomparer.py - About 45 mins to fix

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

                    def create_firewall_rule(self, protocol, action, **kwargs):
                        '''
                        Create a new firlwall rule
                        '''
                        body = {'protocol': protocol, 'action': action}
                Severity: Minor
                Found in salt/utils/openstack/neutron.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 show_ip:
                                            minions.add((id_, ipv6))
                                        else:
                                            minions.add(id_)
                                        break
                Severity: Major
                Found in salt/utils/minions.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if self.__fun_check(ind[valid], fun, args.get('arg'), args.get('kwarg')):
                                              return True
                          return False
                  Severity: Major
                  Found in salt/utils/minions.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if isinstance(cert, six.string_types):
                                            if os.path.exists(cert):
                                                cert_chain = (cert)
                                        elif isinstance(cert, list):
                                            if os.path.exists(cert[0]) and os.path.exists(cert[1]):
                    Severity: Major
                    Found in salt/utils/http.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if hasattr(ssl, 'SSLContext'):
                                              # Python >= 2.7.9
                                              context = ssl.SSLContext.load_cert_chain(*cert_chain)
                                              handlers.append(urllib_request.HTTPSHandler(context=context))  # pylint: disable=E1123
                                          else:
                      Severity: Major
                      Found in salt/utils/http.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if word == 'not':
                                                    results.append('(')
                                                    results.append(six.text_type(set(minions)))
                                                    results.append('-')
                                                    unmatched.append('-')
                        Severity: Major
                        Found in salt/utils/minions.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if self.__fun_check(ind[valid], fun_name, args.get('arg'), args.get('kwarg')):
                                                      return True
                                              if valid[1:] == form or valid == '@{0}s'.format(form):
                          Severity: Major
                          Found in salt/utils/minions.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if not isinstance(val, list):
                                                    temp = [val]
                                                    val = temp
                                                val.append(n.data)
                            Severity: Major
                            Found in salt/utils/namecheap.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if namespace:
                                                      _namespace = '{0}{1}'.format(namespace, _namespace)
                                                  changes[_namespace] = {
                              Severity: Major
                              Found in salt/utils/configcomparer.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if show_ip:
                                                            minions.add((id_, ipv4))
                                                        else:
                                                            minions.add(id_)
                                                        break
                                Severity: Major
                                Found in salt/utils/minions.py - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language