saltstack/salt

View on GitHub
salt/utils/network.py

Summary

Maintainability
F
3 wks
Test Coverage

File network.py has 1624 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''

Severity: Major
Found in salt/utils/network.py - About 4 days to fix

    Function _interfaces_ifconfig has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
    Open

    def _interfaces_ifconfig(out):
        '''
        Uses ifconfig to return a dictionary of interfaces with various information
        about each (up/down state, ip address, netmask, and hwaddr)
        '''
    Severity: Minor
    Found in salt/utils/network.py - About 1 day 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 _interfaces_ip has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
    Open

    def _interfaces_ip(out):
        '''
        Uses ip to return a dictionary of interfaces with various information about
        each (up/down state, ip address, netmask, and hwaddr)
        '''
    Severity: Minor
    Found in salt/utils/network.py - About 1 day 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 dns_check has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

    def dns_check(addr, port=80, safe=False, ipv6=None, attempt_connect=True):
        '''
        Return the ip resolved by dns, but do not exit on failure, only raise an
        exception. Obeys system preference for IPv4/6 address resolution - this
        can be overridden by the ipv6 flag.
    Severity: Minor
    Found in salt/utils/network.py - About 6 hrs 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 _netbsd_interfaces_ifconfig has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    def _netbsd_interfaces_ifconfig(out):
        '''
        Uses ifconfig to return a dictionary of interfaces with various information
        about each (up/down state, ip address, netmask, and hwaddr)
        '''
    Severity: Minor
    Found in salt/utils/network.py - About 5 hrs 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 _generate_minion_id has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def _generate_minion_id():
        '''
        Get list of possible host names and convention names.
    
        :return:
    Severity: Minor
    Found in salt/utils/network.py - About 4 hrs 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 _remotes_on has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    def _remotes_on(port, which_end):
        '''
        Return a set of ip addrs active tcp connections
        '''
        port = int(port)
    Severity: Minor
    Found in salt/utils/network.py - About 4 hrs 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

    Cyclomatic complexity is too high in function _interfaces_ifconfig. (33)
    Open

    def _interfaces_ifconfig(out):
        '''
        Uses ifconfig to return a dictionary of interfaces with various information
        about each (up/down state, ip address, netmask, and hwaddr)
        '''
    Severity: Minor
    Found in salt/utils/network.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function _interfaces_ipconfig has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def _interfaces_ipconfig(out):
        '''
        Returns a dictionary of interfaces with various information about each
        (up/down state, ip address, netmask, and hwaddr)
    
    
    Severity: Minor
    Found in salt/utils/network.py - About 3 hrs 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 parse_host_port has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_host_port(host_port):
        """
        Takes a string argument specifying host or host:port.
    
        Returns a (hostname, port) or (ip_address, port) tuple. If no port is given,
    Severity: Minor
    Found in salt/utils/network.py - About 3 hrs 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 _subnets has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def _subnets(proto='inet', interfaces_=None):
        '''
        Returns a list of subnets to which the host belongs
        '''
        if interfaces_ is None:
    Severity: Minor
    Found in salt/utils/network.py - About 2 hrs 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

    Cyclomatic complexity is too high in function dns_check. (23)
    Open

    @jinja_filter('dns_check')
    def dns_check(addr, port=80, safe=False, ipv6=None, attempt_connect=True):
        '''
        Return the ip resolved by dns, but do not exit on failure, only raise an
        exception. Obeys system preference for IPv4/6 address resolution - this
    Severity: Minor
    Found in salt/utils/network.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function hex2ip has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def hex2ip(hex_ip, invert=False):
        '''
        Convert a hex string to an ip, if a failure occurs the original hex is
        returned. If 'invert=True' assume that ip from /proc/net/<proto>
        '''
    Severity: Minor
    Found in salt/utils/network.py - About 1 hr 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 _linux_remotes_on has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def _linux_remotes_on(port, which_end):
        '''
        Linux specific helper function.
        Returns set of ip host addresses of remote established connections
        on local tcp port port.
    Severity: Minor
    Found in salt/utils/network.py - About 1 hr 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 active_tcp has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def active_tcp():
        '''
        Return a dict describing all active tcp connections as quickly as possible
        '''
        ret = {}
    Severity: Minor
    Found in salt/utils/network.py - About 1 hr 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 _ip_addrs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _ip_addrs(interface=None, include_loopback=False, interface_data=None, proto='inet'):
        '''
        Return the full list of IP adresses matching the criteria
    
        proto = inet|inet6
    Severity: Minor
    Found in salt/utils/network.py - About 1 hr 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 _freebsd_remotes_on has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _freebsd_remotes_on(port, which_end):
        '''
        Returns set of ipv4 host addresses of remote established connections
        on local tcp port port.
    
    
    Severity: Minor
    Found in salt/utils/network.py - About 1 hr 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 _netbsd_remotes_on has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _netbsd_remotes_on(port, which_end):
        '''
        Returns set of ipv4 host addresses of remote established connections
        on local tcp port port.
    
    
    Severity: Minor
    Found in salt/utils/network.py - About 1 hr 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 _netlink_tool_remote_on has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _netlink_tool_remote_on(port, which_end):
        '''
        Returns set of ipv4 host addresses of remote established connections
        on local or remote tcp port.
    
    
    Severity: Minor
    Found in salt/utils/network.py - About 1 hr 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 _sunos_remotes_on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _sunos_remotes_on(port, which_end):
        '''
        SunOS specific helper function.
        Returns set of ipv4 host addresses of remote established connections
        on local or remote tcp port.
    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

    Avoid deeply nested control flow statements.
    Open

                        if mmask.group(1):
                            mmask = _number_of_set_bits_to_ipv4_netmask(
                                int(mmask.group(1), 16))
                        else:
                            mmask = mmask.group(2)
    Severity: Major
    Found in salt/utils/network.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if hst[0][:4] in ('127.', '::1') or len(hst) == 1:
                                  hosts.extend(hst)
              except IOError:
      Severity: Major
      Found in salt/utils/network.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if iret[sl][which_end] == port and iret[sl]['state'] == 1:  # 1 is ESTABLISHED
                                ret.add(iret[sl]['remote_addr'])
        
        
        Severity: Major
        Found in salt/utils/network.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for chunk in data['hwaddr'].split(':'):
                                  expand_mac.append('0{0}'.format(chunk) if len(chunk) < 2 else '{0}'.format(chunk))
                              data['hwaddr'] = ':'.join(expand_mac)
          Severity: Major
          Found in salt/utils/network.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if iret[sl]['state'] == 1:  # 1 is ESTABLISHED
                                    del iret[sl]['state']
                                    ret[len(ret)] = iret[sl]
                return ret
            Severity: Major
            Found in salt/utils/network.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if line.strip().startswith('sl'):
                                      continue
                                  iret = _parse_tcp_line(line)
              Severity: Major
              Found in salt/utils/network.py - About 45 mins to fix

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

                def _windows_remotes_on(port, which_end):
                    r'''
                    Windows specific helper function.
                    Returns set of ipv4 host addresses of remote established connections
                    on local or remote tcp port.
                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 _aix_remotes_on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _aix_remotes_on(port, which_end):
                    '''
                    AIX specific helper function.
                    Returns set of ipv4 host addresses of remote established connections
                    on local or remote tcp port.
                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 _openbsd_remotes_on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _openbsd_remotes_on(port, which_end):
                    '''
                    OpenBSD specific helper function.
                    Returns set of ipv4 host addresses of remote established connections
                    on local or remote tcp port.
                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

                Avoid deeply nested control flow statements.
                Open

                                    if 'secondary' not in cols:
                                        ipaddr, netmask, broadcast, scope = parse_network(value, cols)
                                        if type_ == 'inet':
                                            if 'inet' not in data:
                                                data['inet'] = list()
                Severity: Major
                Found in salt/utils/network.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if line.strip().startswith('sl'):
                                          continue
                                      iret = _parse_tcp_line(line)
                  Severity: Major
                  Found in salt/utils/network.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if not salt.utils.platform.is_sunos():
                                            ipv6scope = mmask6.group(3) or mmask6.group(4)
                                            addr_obj['scope'] = ipv6scope.lower() if ipv6scope is not None else ipv6scope
                                    # SunOS sometimes has ::/0 as inet6 addr when using addrconf
                                    if not salt.utils.platform.is_sunos() \
                    Severity: Major
                    Found in salt/utils/network.py - About 45 mins to fix

                      Function _ip_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _ip_options(ip_obj, version, options=None):
                      
                          # will process and IP options
                          options_fun_map = {
                              'global': _ip_options_global,
                      Severity: Minor
                      Found in salt/utils/network.py - About 35 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 _filter_ipaddr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _filter_ipaddr(value, options, version=None):
                          ipaddr_filter_out = None
                          if version:
                              if version == 4:
                                  ipaddr_filter_out = ipv4(value, options)
                      Severity: Minor
                      Found in salt/utils/network.py - About 35 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_fqhostname has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_fqhostname():
                          '''
                          Returns the fully qualified hostname
                          '''
                          # try getaddrinfo()
                      Severity: Minor
                      Found in salt/utils/network.py - About 35 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 too many return statements within this function.
                      Open

                                  return _windows_remotes_on(port, which_end)
                      Severity: Major
                      Found in salt/utils/network.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return _linux_remotes_on(port, which_end)
                        Severity: Major
                        Found in salt/utils/network.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return _aix_remotes_on(port, which_end)
                          Severity: Major
                          Found in salt/utils/network.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return ret
                            Severity: Major
                            Found in salt/utils/network.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return '{0}.{1}.{2}.{3}'.format(hip >> 24 & 255,
                              Severity: Major
                              Found in salt/utils/network.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return '{3}.{2}.{1}.{0}'.format(hip >> 24 & 255,
                                Severity: Major
                                Found in salt/utils/network.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return _openbsd_remotes_on(port, which_end)
                                  Severity: Major
                                  Found in salt/utils/network.py - About 30 mins to fix

                                    Function _is_ipv has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    def _is_ipv(ip, version, options=None):
                                    
                                        if not version:
                                            version = 4
                                    
                                    
                                    Severity: Minor
                                    Found in salt/utils/network.py - About 25 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 host_to_ips has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    def host_to_ips(host):
                                        '''
                                        Returns a list of IP addresses of a given hostname or None if not found.
                                        '''
                                        ips = []
                                    Severity: Minor
                                    Found in salt/utils/network.py - About 25 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

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    def _sunos_remotes_on(port, which_end):
                                        '''
                                        SunOS specific helper function.
                                        Returns set of ipv4 host addresses of remote established connections
                                        on local or remote tcp port.
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 1 day to fix
                                    salt/utils/network.py on lines 1756..1803

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 205.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    def _aix_remotes_on(port, which_end):
                                        '''
                                        AIX specific helper function.
                                        Returns set of ipv4 host addresses of remote established connections
                                        on local or remote tcp port.
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 1 day to fix
                                    salt/utils/network.py on lines 1467..1502

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 205.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    @jinja_filter('network_size')
                                    def network_size(value, options=None, version=None):
                                        '''
                                        Get the size of a network.
                                        '''
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 4 hrs to fix
                                    salt/utils/network.py on lines 534..550

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 92.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    @jinja_filter('network_hosts')
                                    def network_hosts(value, options=None, version=None):
                                        '''
                                        Return the list of hosts within a network.
                                    
                                    
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 4 hrs to fix
                                    salt/utils/network.py on lines 559..570

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 92.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                if 'inet6' in data:
                                                    ret[iface]['inet6'].extend(x for x in data['inet6'] if x not in ret[iface]['inet6'])
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 2 hrs to fix
                                    salt/utils/network.py on lines 833..834

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 65.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                if 'inet' in data:
                                                    ret[iface]['inet'].extend(x for x in data['inet'] if x not in ret[iface]['inet'])
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 2 hrs to fix
                                    salt/utils/network.py on lines 835..836

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 65.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        try:
                                            cmd = salt.utils.args.shlex_split('sockstat -4 -c -p {0}'.format(port))
                                            data = subprocess.check_output(cmd)  # pylint: disable=minimum-python-version
                                        except subprocess.CalledProcessError as ex:
                                            log.error('Failed "sockstat" with returncode = %s', ex.returncode)
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 1 hr to fix
                                    salt/utils/network.py on lines 1588..1593

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 56.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        try:
                                            cmd = salt.utils.args.shlex_split('sockstat -4 -c -n -p {0}'.format(port))
                                            data = subprocess.check_output(cmd)  # pylint: disable=minimum-python-version
                                        except subprocess.CalledProcessError as ex:
                                            log.error('Failed "sockstat" with returncode = %s', ex.returncode)
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 1 hr to fix
                                    salt/utils/network.py on lines 1528..1533

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 56.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        if invert:
                                            return '{3}.{2}.{1}.{0}'.format(hip >> 24 & 255,
                                                                            hip >> 16 & 255,
                                                                            hip >> 8 & 255,
                                                                            hip & 255)
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 1 hr to fix
                                    salt/utils/network.py on lines 1297..1300

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 54.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        return '{0}.{1}.{2}.{3}'.format(hip >> 24 & 255,
                                                                        hip >> 16 & 255,
                                                                        hip >> 8 & 255,
                                                                        hip & 255)
                                    Severity: Major
                                    Found in salt/utils/network.py and 1 other location - About 1 hr to fix
                                    salt/utils/network.py on lines 1292..1296

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 54.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            cmd2 = subprocess.Popen(
                                                '{0} addr show'.format(ip_path),
                                                shell=True,
                                                close_fds=True,
                                                stdout=subprocess.PIPE,
                                    Severity: Minor
                                    Found in salt/utils/network.py and 1 other location - About 50 mins to fix
                                    salt/utils/network.py on lines 851..856

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 44.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                            cmd1 = subprocess.Popen(
                                                '{0} link show'.format(ip_path),
                                                shell=True,
                                                close_fds=True,
                                                stdout=subprocess.PIPE,
                                    Severity: Minor
                                    Found in salt/utils/network.py and 1 other location - About 50 mins to fix
                                    salt/utils/network.py on lines 857..862

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 44.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    def is_ipv6_subnet(cidr):
                                        '''
                                        Returns a bool telling if the passed string is an IPv6 subnet
                                        '''
                                        try:
                                    Severity: Minor
                                    Found in salt/utils/network.py and 1 other location - About 45 mins to fix
                                    salt/utils/network.py on lines 289..296

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 43.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    def is_ipv4_subnet(cidr):
                                        '''
                                        Returns a bool telling if the passed string is an IPv4 subnet
                                        '''
                                        try:
                                    Severity: Minor
                                    Found in salt/utils/network.py and 1 other location - About 45 mins to fix
                                    salt/utils/network.py on lines 299..306

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 43.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    @jinja_filter('is_ipv4')
                                    def is_ipv4_filter(ip, options=None):
                                        '''
                                        Returns a bool telling if the value passed to it was a valid IPv4 address.
                                    
                                    
                                    Severity: Minor
                                    Found in salt/utils/network.py and 1 other location - About 40 mins to fix
                                    salt/utils/network.py on lines 430..445

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 42.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                    @jinja_filter('is_ipv6')
                                    def is_ipv6_filter(ip, options=None):
                                        '''
                                        Returns a bool telling if the value passed to it was a valid IPv6 address.
                                    
                                    
                                    Severity: Minor
                                    Found in salt/utils/network.py and 1 other location - About 40 mins to fix
                                    salt/utils/network.py on lines 412..427

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 42.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                            cmd = subprocess.Popen(
                                                '{0} -a'.format(ifconfig_path),
                                                shell=True,
                                                stdout=subprocess.PIPE,
                                                stderr=subprocess.STDOUT).communicate()[0]
                                    Severity: Minor
                                    Found in salt/utils/network.py and 2 other locations - About 35 mins to fix
                                    salt/utils/network.py on lines 947..951
                                    salt/utils/network.py on lines 1083..1087

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 41.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        cmd = subprocess.Popen(
                                            'entstat -d {0} | grep \'Hardware Address\''.format(iface),
                                            shell=True,
                                            stdout=subprocess.PIPE,
                                            stderr=subprocess.STDOUT).communicate()[0]
                                    Severity: Minor
                                    Found in salt/utils/network.py and 2 other locations - About 35 mins to fix
                                    salt/utils/network.py on lines 867..871
                                    salt/utils/network.py on lines 947..951

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 41.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 3 locations. Consider refactoring.
                                    Open

                                        cmd = subprocess.Popen(
                                            '{0} -a'.format(ifconfig_path),
                                            shell=True,
                                            stdout=subprocess.PIPE,
                                            stderr=subprocess.STDOUT).communicate()[0]
                                    Severity: Minor
                                    Found in salt/utils/network.py and 2 other locations - About 35 mins to fix
                                    salt/utils/network.py on lines 867..871
                                    salt/utils/network.py on lines 1083..1087

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 41.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    There are no issues that match your filters.

                                    Category
                                    Status