saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        for host in ret:
                            cret[host] = ret[host]['ret']
                        return cret
Severity: Major
Found in salt/modules/publish.py - About 45 mins to fix

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

    def locate(pattern, database='', limit=0, **kwargs):
        '''
        Performs a file lookup. Valid options (and their defaults) are::
    
            basename=False
    Severity: Minor
    Found in salt/modules/locate.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 ip_ in host_ips:
                            containers = proxy_lists[container['Image']].setdefault('ipv4', {}).setdefault(dock_port['PrivatePort'], [])
                            container_network_footprint = '{0}:{1}'.format(ip_, dock_port['PublicPort'])
                            if with_container_id:
                                value = (container_network_footprint, container_id)
    Severity: Major
    Found in salt/modules/mine.py - About 45 mins to fix

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

      def recv(files, dest):
          '''
          Used with salt-cp, pass the files dict, and the destination.
      
          This function receives small fast copy files from the master via salt-cp.
      Severity: Minor
      Found in salt/modules/cp.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 salt.utils.network.in_subnet(cidr, [ip_]):
                              good_ips.append(ip_)
                  host_ips = list(set(good_ips))
      Severity: Major
      Found in salt/modules/mine.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if with_container_id:
                                value = (container_network_footprint, container_id)
                            else:
                                value = container_network_footprint
                            if value not in containers:
        Severity: Major
        Found in salt/modules/mine.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if acl_type == 'acl':
                                  ret[dentry][entity] = [{"": vals}]
                              elif acl_type == 'default':
                                  if 'defaults' not in ret[dentry]:
                                      ret[dentry]['defaults'] = {}
          Severity: Major
          Found in salt/modules/linux_acl.py - About 45 mins to fix

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

            def _exec(client, tgt, fun, arg, timeout, tgt_type, ret, kwarg, **kwargs):
                fcn_ret = {}
                seen = 0
                if 'batch' in kwargs:
                    _cmd = client.cmd_batch
            Severity: Minor
            Found in salt/modules/saltutil.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 acl_type == 'acl':
                                    ret[dentry][entity].append({usergroup: vals})
                                elif acl_type == 'default':
                                    if 'defaults' not in ret[dentry]:
                                        ret[dentry]['defaults'] = {}
            Severity: Major
            Found in salt/modules/linux_acl.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if value not in containers:
                                      containers.append(value)
              
              
              Severity: Major
              Found in salt/modules/mine.py - About 45 mins to fix

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

                def delta_import(handler, host=None, core_name=None, options=None, extra=None):
                    '''
                    Submits an import command to the specified handler using specified options.
                    This command can only be run if the minion is configured with
                    solr.type=master
                Severity: Minor
                Found in salt/modules/solr.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 create_api_integration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def create_api_integration(restApiId, resourcePath, httpMethod, integrationType, integrationHttpMethod,
                                           uri, credentials, requestParameters=None, requestTemplates=None,
                                           region=None, key=None, keyid=None, profile=None):
                    '''
                    Creates an integration for a given method in a given API.
                Severity: Minor
                Found in salt/modules/boto_apigateway.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 shutdown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def shutdown(zone, reboot=False, single=False, altinit=None, smf_options=None):
                    '''
                    Gracefully shutdown the specified zone.
                
                    zone : string
                Severity: Minor
                Found in salt/modules/zoneadm.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 ping has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def ping(host=None, core_name=None):
                    '''
                    Does a health check on solr, makes sure solr can talk to the indexes.
                
                    host : str (None)
                Severity: Minor
                Found in salt/modules/solr.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 mod_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def mod_list(only_persist=False):
                    '''
                    Return a list of the loaded module names
                
                    CLI Example:
                Severity: Minor
                Found in salt/modules/freebsdkmod.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 write_pem has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def write_pem(text, path, overwrite=True, pem_type=None):
                    '''
                    Writes out a PEM string fixing any formatting or whitespace
                    issues before writing.
                
                
                Severity: Minor
                Found in salt/modules/x509.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 _create_and_add_parameters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _create_and_add_parameters(params):
                    '''
                    Parses the configuration and creates Parameter instances.
                    '''
                    global _current_parameter
                Severity: Minor
                Found in salt/modules/syslog_ng.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 optimize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def optimize(host=None, core_name=None):
                    '''
                    Search queries fast, but it is a very expensive operation. The ideal
                    process is to run this with a master/slave configuration.  Then you
                    can optimize the master, and push the optimized index to the slaves.
                Severity: Minor
                Found in salt/modules/solr.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 get_rule_handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_rule_handle(table='filter', chain=None, rule=None, family='ipv4'):
                    '''
                    Get the handle for a particular rule
                
                    This function accepts a rule in a standard nftables command format,
                Severity: Minor
                Found in salt/modules/nftables.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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def start(name=None,
                          user=None,
                          group=None,
                          chroot=None,
                          caps=None,
                Severity: Minor
                Found in salt/modules/syslog_ng.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