saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    for port_key, port_value in iteritems(port):
                        if hasattr(kube_port, port_key):
                            setattr(kube_port, port_key, port_value)
                else:
Severity: Major
Found in salt/modules/kubernetesmod.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (
                            cid == SALT_CRON_NO_IDENTIFIER
                        ):
                            if identifier:
                                cid = identifier
    Severity: Major
    Found in salt/modules/cron.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if (
                              cid == SALT_CRON_NO_IDENTIFIER
                          ):
                              if identifier:
                                  cid = identifier
      Severity: Major
      Found in salt/modules/cron.py - About 45 mins to fix

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

        def _reset_syslog_config_params(host, username, password, cmd, resets, valid_resets,
                                        protocol=None, port=None, esxi_host=None, credstore=None):
            '''
            Helper function for reset_syslog_config that resets the config and populates the return dictionary.
            '''
        Severity: Minor
        Found in salt/modules/vsphere.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 a not in valid_attrs:
                                ret['result'] = False
                                ret['comment'] = '{0} is not a valid attribute for table {1}'.format(a, table)
                                return ret
                        _attrs = ','.join(attrs)
        Severity: Major
        Found in salt/modules/osquery.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if all_attr[key]:
                                  filtered_attr[key] = all_attr[key]
                          versions.append(filtered_attr)
          Severity: Major
          Found in salt/modules/pkg_resource.py - About 45 mins to fix

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

            def init(storage_backend='dir', trust_password=None, network_address=None,
                     network_port=None, storage_create_device=None,
                     storage_create_loop=None, storage_pool=None):
                '''
                Calls lxd init --auto -- opts
            Severity: Minor
            Found in salt/modules/lxd.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 remove_capacity_from_diskgroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def remove_capacity_from_diskgroup(cache_disk_id, capacity_disk_ids,
                                               data_evacuation=True, safety_checks=True,
                                               service_instance=None):
                '''
                Remove capacity disks from the disk group with the specified cache disk.
            Severity: Minor
            Found in salt/modules/vsphere.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 __read_and_render_yaml_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def __read_and_render_yaml_file(source,
                                            template,
                                            saltenv):
                '''
                Read a yaml file and, if needed, renders that using the specifieds
            Severity: Minor
            Found in salt/modules/kubernetesmod.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(parts[1]) > 1:
                                    identifier = parts[1][1:]
            
            
            Severity: Major
            Found in salt/modules/cron.py - About 45 mins to fix

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

              def download(*packages, **kwargs):
                  '''
                  Download packages to the local disk.
              
                  refresh
              Severity: Minor
              Found in salt/modules/zypperpkg.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 line.strip():
                                      continue
                                  if not line.startswith('jail_list='):
              Severity: Major
              Found in salt/modules/freebsdjail.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not line.startswith('jail_list='):
                                        continue
                                    jails = line.split('"')[1].split()
                Severity: Major
                Found in salt/modules/freebsdjail.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      for line in _fp:
                                          line = salt.utils.stringutils.to_unicode(line)
                                          if not line.strip():
                                              continue
                                          if not line.startswith('jail_{0}_'.format(jail)):
                  Severity: Major
                  Found in salt/modules/freebsdjail.py - About 45 mins to fix

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

                    def agent_maintenance(consul_url=None, token=None, **kwargs):
                        '''
                        Manages node maintenance mode
                    
                        :param consul_url: The Consul server URL.
                    Severity: Minor
                    Found in salt/modules/consul.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_grants has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def list_grants(key_id, limit=None, marker=None, region=None, key=None,
                                    keyid=None, profile=None):
                        '''
                        List grants for the specified key.
                    
                    
                    Severity: Minor
                    Found in salt/modules/boto_kms.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 set_logging_levels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def set_logging_levels(remote=None, local=None):
                        '''
                        Sets the logging levels of the CIMC devices. The logging levels must match
                        the following options: emergency, alert, critical, error, warning, notice,
                        informational, debug.
                    Severity: Minor
                    Found in salt/modules/cimc.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

                                        for j in jails:
                                            ret.append(j)
                        return ret
                    Severity: Major
                    Found in salt/modules/freebsdjail.py - About 45 mins to fix

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

                      def _regex_iptables_save(cmd_output, filters=None):
                          '''
                          Return string with `save_filter` regex entries removed.  For example:
                      
                          If `filters` is not provided, it will be pulled from minion config,
                      Severity: Minor
                      Found in salt/modules/iptables.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 options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def options(name, conf_file=None):
                          '''
                          .. versionadded:: 2014.1.0
                      
                          Read the config file and return the config options for a given process
                      Severity: Minor
                      Found in salt/modules/supervisord.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

                      Severity
                      Category
                      Status
                      Source
                      Language