saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not signaled:
                        ret['killed'] = pid
                        break
                else:
Severity: Major
Found in salt/modules/minion.py - About 45 mins to fix

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

    def banner(width=72, commentchar='#', borderchar='#', blockstart=None, blockend=None,
               title=None, text=None, newline=False):
        '''
        Create a standardized comment block to include in a templated file.
    
    
    Severity: Minor
    Found in salt/modules/slsutil.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 _check_xenapi has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _check_xenapi():
        if __grains__.get('os') == 'Debian':
            debian_xen_version = '/usr/lib/xen-common/bin/xen-version'
            if os.path.isfile(debian_xen_version):
                # __salt__ is not available in __virtual__
    Severity: Minor
    Found in salt/modules/xapi_virt.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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def show(name, root=None):
        '''
        .. versionadded:: 2014.7.0
    
        Show properties of one or more units/jobs or the manager
    Severity: Minor
    Found in salt/modules/systemd_service.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 resource_absent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def resource_absent(resource, identifier_fields, profile='pagerduty', subdomain=None, api_key=None, **kwargs):
        '''
        Generic resource.absent state method.   Pagerduty state modules should be a thin wrapper over this method,
        with a custom diff function.
    
    
    Severity: Minor
    Found in salt/modules/pagerduty_util.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 convert_to_group_ids has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def convert_to_group_ids(groups, vpc_id=None, vpc_name=None, region=None, key=None,
                             keyid=None, profile=None):
        '''
        Given a list of security groups and a vpc_id, convert_to_group_ids will
        convert all list items in the given list to security group ids.
    Severity: Minor
    Found in salt/modules/boto_secgroup.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 user_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_list(user=None, password=None, host=None, port=None, database='admin', authdb=None):
        '''
        List users of a MongoDB database
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/mongodb.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 delete_tags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def delete_tags(tags,
                    name=None,
                    group_id=None,
                    vpc_name=None,
                    vpc_id=None,
    Severity: Minor
    Found in salt/modules/boto_secgroup.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 name in files:
                                    filenames.append(os.path.join(root, name))
    
    
    Severity: Major
    Found in salt/modules/restartcheck.py - About 45 mins to fix

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

          def call(self, module, *args, **kwargs):
              '''
              Call an Ansible module by invoking it.
              :param module: the name of the module.
              :param args: Arguments to the module
      Severity: Minor
      Found in salt/modules/ansiblegate.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_snapshot_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _get_snapshot_url(nexus_url, repository, group_id, artifact_id, version, packaging, snapshot_version=None, classifier=None, headers=None, just_get_version_string=None):
          if headers is None:
              headers = {}
          has_classifier = classifier is not None and classifier != ""
      
      
      Severity: Minor
      Found in salt/modules/nexus.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 ignore_epoch is True:
                              version_num = version_num.split(':', 1)[-1]
                      arch = ''
      Severity: Major
      Found in salt/modules/yumpkg.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          if change.name == 'info':
                             state = change.val.state
                          elif change.name == 'info.state':
                             state = change.val
                          else:
        Severity: Major
        Found in salt/ext/vsan/vsanapiutils.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            if state == vim.TaskInfo.State.success:
                               # Remove task from taskList
                               taskList.remove(str(task))
                            elif state == vim.TaskInfo.State.error:
                               raise task.info.error
          Severity: Major
          Found in salt/ext/vsan/vsanapiutils.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if target is None:
                                    errors.append(
                                        'No version matching \'{0}{1}\' could be found '
                                        '(available: {2})'.format(
                                            pkgname,
            Severity: Major
            Found in salt/modules/yumpkg.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  for p_type in pkgtypes:
                                      ret[p_type].update(set(expanded[p_type]))
                              else:
              Severity: Major
              Found in salt/modules/yumpkg.py - About 45 mins to fix

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

                def _dnsname_match(dn, hostname, max_wildcards=1):
                    """Matching according to RFC 6125, section 6.4.3
                
                    http://tools.ietf.org/html/rfc6125#section-6.4.3
                    """
                Severity: Minor
                Found in salt/ext/ssl_match_hostname.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 group_diff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def group_diff(name):
                    '''
                    .. versionadded:: 2014.1.0
                    .. versionchanged:: 2016.3.0,2015.8.4,2015.5.10
                        Environment groups are now supported. The key names have been renamed,
                Severity: Minor
                Found in salt/modules/yumpkg.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 inet_ntop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def inet_ntop(address_family, packed_ip):
                    addr = sockaddr()
                    addr.sa_family = address_family
                    addr_size = ctypes.c_int(ctypes.sizeof(addr))
                    ip_string = ctypes.create_string_buffer(128)
                Severity: Minor
                Found in salt/ext/win_inet_pton.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(self, address, strict=True):
                        """Instantiate a new IPv6 Network object.
                
                        Args:
                            address: A string or integer representing the IPv6 network or the
                Severity: Minor
                Found in salt/ext/ipaddress.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